# java.sql.Driver

Attention: Derby Version 10.2 includes JDBC 4.0 functionality based on a pre-release of Java SE 6. When you use Derby with a Java SE 6 virtual machine, Derby will use its JDBC 3.0 drivers, just as with 1.4 and 1.5 virtual machines. JDBC 4.0 is available only to developers who download Java SE 6 and use it to build in support for JDBC 4.0. The Release Notes explain how to build the JDBC 4.0 functionality with Derby Version 10.2. A follow-on Derby release will include JDBC 4.0 functionality based on the final JDBC 4.0 specification once Java SE 6 becomes generally available.
The class that loads Derby's local JDBC driver is the class org.apache.derby.jdbc.EmbeddedDriver. Listed below are some of the ways to create instances of that class. Do not use the class directly through the java.sql.Driver interface. Use the DriverManager class to create connections.

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

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

  Our recommended manner, because it ensures that the class is loaded in all JVMs by creating an instance at the same time.

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

  Same as Class.forName("org.apache.derby.jdbc.EmbeddedDriver"), except that it requires the class to be found when the code is compiled.

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

  This is also the same as Class.forName("org.apache.derby.jdbc.EmbeddedDriver"), 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

The actual driver that gets registered in the DriverManager to handle the jdbc:derby: protocol is not the class org.apache.derby.jdbc.EmbeddedDriver; 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.

Parent topic: JDBC Reference
Related concepts
Core JDBC java.sql Classes, Interfaces, and Methods
Related reference
java.sql.DriverManager.getConnection
java.sql.Driver.getPropertyInfo
java.sql.Connection
java.sql.DatabaseMetaData
java.sql.Statement
java.sql.CallableStatement
java.sql.SQLException
java.sql.PreparedStatement
java.sql.ResultSet
java.sql.ResultSetMetaData
java.sql.SQLWarning
java.sql.SQLXML
Mapping of java.sql.Types to SQL types
java.sql.Blob and java.sql.Clob
java.sql.Connection
java.sql.ResultSet
java.sql.Statement
java.sql.PreparedStatement
java.sql.CallableStatement
java.sql.DatabaseMetaData
java.sql.ResultSetMetaData
java.sql.BatchUpdateException
JDBC Package for Connected Device Configuration/Foundation Profile (JSR169)
JDBC 3.0-only features
JDBC 4.0-only features
JDBC escape syntax