This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Connection is interface so how can we access it createStatement() on connection objec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply locked New topic
Author

Connection is interface so how can we access it createStatement() on connection objec

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 Statement
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

belongs in Beginner's forum.

Connection is an interface, but DriverManager.getConnection() returns an object which implements this interface. Interface is only telling you what methods that implementation object will have.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Please don't post the same question in multiple forums. It makes answers harder to follow and wastes people's time answering the same question. I'll close this copy and we can continue discussion in the JDBC thread.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Connection is interface so how can we access it createStatement() on connection objec