This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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").