| 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("jdbc dbc: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("jdbc  dbc: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.
|
 |
 |
|
|
subject: Connection is a interface & so how can we access it createStatement() on con object?
|
|
|