aspose file tools
The moose likes JDBC and the fly likes Connection is a interface & so how can we access it createStatement() on con object? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Connection is a interface & so how can we access it createStatement() on con object?" Watch "Connection is a interface & so how can we access it createStatement() on con object?" New topic
Author

Connection is a interface & so how can we access it createStatement() on con object?

Ami Ambre
Ranch Hand

Joined: Dec 26, 2007
Posts: 58
But Connection is a interface & so how can we access it

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbcdbc:student");

Statement st = con.createStatement();
Creates a Statement object for sending SQL statements to the database
ReturnType of createStatement() is Statemen
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3829
Originally posted by Ami Ambre:
But Connection is a interface & so how can we access it

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbcdbc:student");

Statement st = con.createStatement();
Creates a Statement object for sending SQL statements to the database
ReturnType of createStatement() is Statemen


You (compiler) call (not exactly call, bind is more appropriate) method on reference and JVM calls method on object, the reference point to.

In other word, at compile time methods are bind with the reference and at run time methods are executed by object, the reference point to.

Now you figure out what's happening above.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Connection is a interface & so how can we access it createStatement() on con object?
 
Similar Threads
which concrete class has the implementation for createStatement method
Connection is interface so how can we access it createStatement() on connection objec
Why class DriverManager can use methods of interface Connection??
Interfaces
JDBC