JDBC reference
Derby Reference Manual
302
JDBC reference
Derby comes with a built-in JDBC driver.
That makes the JDBC API the only API for working with Derby databases. The driver is a
native-protocol fully Java technology-enabled driver (Type 4 of the types described under
"JDBC Architecture" in
).
This section provides reference information about Derby's implementation of the JDBC
API and documents the way it conforms to the JDBC 3.0 and 4.0 APIs.
See the Derby Developer's Guide for task-oriented instructions on working with the driver.
This JDBC driver implements the standard JDBC interfaces. When invoked from an
application running in the same Java Virtual Machine (JVM) as Derby, the JDBC driver
supports connections to a Derby database in embedded mode. No network transport is
required to access the database. In client/server mode, the client application dispatches
JDBC requests to the JDBC server over a network; the server, in turn, which runs in the
same JVM as Derby, sends requests to Derby through the embedded JDBC driver.
The Derby JDBC implementation provides access to Derby databases and supplies
all the required JDBC interfaces. Unimplemented aspects of the JDBC driver return an
SQLException with a message stating "Feature not implemented" and an SQLState of
XJZZZ. These unimplemented parts are for features not supported by Derby.
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.deregisterDriver 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