This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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


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: 352

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: 32481
    
214

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.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Connection is interface so how can we access it createStatement() on connection objec
 
It's not a secret anymore!