wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30075
    
149

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
 
Similar Threads
Connection is a interface & so how can we access it createStatement() on con object?
Please explain my problem
CreateStatement() belongs to which class ???
which concrete class has the implementation for createStatement method
JDBC