Hi folks
I am new to java programming.Can anyone suggest me some good reading for JDBC connection.
I have to connect my java program to a database.
Also while searching on net i found the following statement a bit confusing
1)Connection dbConnection=DriverManager.getConnection(url,”loginName”,”Password”)
2)Statement statement = dbConnection.createStatement();
In the second statement “createStatement” is a method of “Interface Connection”.
How can i call a method of an interface??
Ajay,
JDBC is an API (Standard) published by Sun (now Oracle 🙁 )..
When you code, you use the API to write the code based in interfaces (NOTE: Open javadoc and see… JDBC is a collection of interfaces.. java.sql.* package)
When you want to run the application, you have to use an implementation provided by the Database vendor…
All DB vendors that provide JDBC support have to provide this implementation. classes12.jar or ojdbc14.jar etc… Open that jar file in zip utility and you can see the classes java.sql.Interface and so on…
those are the concrete classes that implement the interfaces that you asked about in your question….
SO you are actually using a concrete class. Learn about inheritance in java.
these may help you
http://www.oracle.com/technetwork/java/overview-141217.html
http://download.oracle.com/javase/tutorial/jdbc/basics/index.html
http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
http://www.roseindia.net/jdbc/jdbc.shtml [good hands on tutorial]
hope this helps…
Thanks.