# java.sql.Driver interface

The class that loads Derby's local JDBC driver is the class org.apache.derby.jdbc.EmbeddedDriver. The class that loads Derby's network client driver is the class org.apache.derby.jdbc.ClientDriver. Listed below are some of the ways to create instances of these classes. Do not use the classes directly through the java.sql.Driver interface. Use the DriverManager class to create connections.

If your application runs on JDK 6 or higher, you do not need to do any of the following. The driver will load automatically when your application asks for its first connection.

-     Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
      Class.forName("org.apache.derby.jdbc.ClientDriver");

  The recommended way to load the driver class.

  With the embedded driver, if your application shuts down Derby or calls the DriverManager.unload method, and you then want to reload the driver, call the Class.forName().newInstance() method to do so:

      Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();

-     new org.apache.derby.jdbc.EmbeddedDriver();
      new org.apache.derby.jdbc.ClientDriver();

  Same as using Class.forName(), except that it requires the class to be found when the code is compiled.

-     Class c = org.apache.derby.jdbc.EmbeddedDriver.class;
      Class c = org.apache.derby.jdbc.ClientDriver.class;

  This is also the same as using Class.forName(), except that it requires the class to be found when the code is compiled. The pseudo-static field class evaluates to the class that is named.

- Setting the system property jdbc.drivers

  To set a system property, you alter the invocation command line or the system properties within your application. It is not possible to alter system properties within an applet.

      java -Djdbc.drivers=org.apache.derby.jdbc.EmbeddedDriver
          applicationClass

      java -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
          applicationClass

The actual driver that gets registered in the DriverManager to handle the jdbc:derby: protocol is not the class org.apache.derby.jdbc.EmbeddedDriver or org.apache.derby.jdbc.ClientDriver; that class simply detects the type of Derby driver needed and then causes the appropriate Derby driver to be loaded.

The only supported way to connect to a Derby system through the jdbc:derby: protocol is using the DriverManager to obtain a driver (java.sql.Driver) or connection (java.sql.Connection) through the getDriver and getConnection method calls.

- java.sql.Driver.getPropertyInfo method

Parent topic: JDBC reference
Related reference
java.sql.DriverManager.getConnection method
java.sql.Connection interface
java.sql.DatabaseMetaData interface
java.sql.Statement interface
java.sql.CallableStatement interface
java.sql.PreparedStatement interface
java.sql.ResultSet interface
java.sql.ResultSetMetaData interface
java.sql.SQLException class
java.sql.SQLWarning class
java.sql.Savepoint interface
Mapping of java.sql.Types to SQL types
JDBC Package for Connected Device Configuration/Foundation Profile (JSR 169)
JDBC 4.0-only features
JDBC escape syntax