This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
interface Connection in package java.sql
Posted by Arjan van der Meer on December 15, 2000 at 4:36 PM
I am wondering why the following code works.
Im my understanding Connection is an interface in class java.sql.
An interface cannot be instantiated andshou;d have all its methods
implemented by the clss that implements the interface.
But which class implements Connection here ? Where is the
implementation of the method createStatement() ?
Thank you for your help,
public static void main (String args )
// Load the Oracle JDBC driver
// Connect to the database
// You must put a database name after the @ sign in the connection URL.
// You can use either the fully specified SQL*net syntax or a short cut
// syntax as ::. The example uses the short cut syntax.
Connection conn =
// Create a Statement HOW IS THIS POSSIBLE ??
Statement stmt = conn.createStatement ();
// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));