permaculture playing cards*
The moose likes JDBC and the fly likes JDBC: What is the concrete class that implements the jdbc interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC: What is the concrete class that implements the jdbc interfaces" Watch "JDBC: What is the concrete class that implements the jdbc interfaces" New topic
Author

JDBC: What is the concrete class that implements the jdbc interfaces

prasad regula
Greenhorn

Joined: Jul 03, 2006
Posts: 24
In a jdbc code, I am mentioning a sample code below for our reference, we come across
Connections, Statements, PreparedStatement, ResultSet. All these are interfaces. In which part of the jdbc code are we coming across a concrete class. We cant execute a code without a concrete class, by just using interfaces. I am not able to identify what class is the real concrete that is executing this jdbc code.




PRSubject
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

That's the whole point of interfaces -- you don't want or need to know!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39543
    
  27
Somewhere you have a jar file that contains the MySQL JDBC driver - the classes that implement those interfaces are in that jar file.


Ping & DNS - updated with new look and Ping home screen widget
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Why not add a line such as:

System.out.println("conn is a " + conn.getClass());

That should tell you the concrete class implementing that interface. You can do the same for the other interfaces.

The "magic" behind the way that JDBC works is that you ask the DriverManager for a connection using a URL. The DriverManager gives you a concrete class that implements the Connection interface. You then turn around and ask the concrete class that implements the Connection interface for a Statement, so that concrete class returns another concrete class that implements the Statement interface. Notice that in this whole scenario that you never "new" anything (that is, you never write "xxx = new XXX").


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC: What is the concrete class that implements the jdbc interfaces
 
Similar Threads
Database Connection
Not to execute console based jdbc application
Need help with my first JDBC program
illegal start of expression
How to create SQL server2005 database on remote machine using jdbc?