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