File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30546
    
150

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
 
jQuery in Action, 2nd edition
 
subject: Connection is interface so how can we access it createStatement() on connection objec