java.sql.Driver.getPropertyInfo method
Derby Reference Manual
303
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
To get the DriverPropertyInfo object, request the JDBC driver from the driver manager:
java.sql.DriverManager.getDriver("jdbc:derby:").
getPropertyInfo(URL, Prop)
Do not request it from org.apache.derby.jdbc.EmbeddedDriver, which is only an
intermediary class that loads the actual driver.
This method might return a DriverPropertyInfo object. In a Derby system, it consists
of an array of database connection URL attributes. The most useful attribute is
, which means that the object consists of a list of
booted databases in the current system.
For example, if a Derby system has the databases toursDB and flightsDB in its
system directory, all the databases in the system are set to boot automatically, and a
user has also connected to a database
A:/dbs/tours94
, the array returned from
getPropertyInfo contains one object corresponding to the databaseName attribute. The
choices field of the DriverPropertyInfo object will contain an array of three Strings with the
values toursDB, flightsDB, and
A:/dbs/tours94
. Note that this object is returned only if
the proposed connection objects do not already include a database name (in any form) or
include the shutdown attribute with the value true.
For more information about java.sql.Driver.getPropertyInfo, see "Offering connection
choices to the user" in the Derby Developer's Guide.
java.sql.DriverManager.getConnection method
A Java application using the JDBC API establishes a connection to a database by
obtaining a Connection object. The standard way to obtain a Connection object is to call
the method DriverManager.getConnection, which takes a String containing a database
connection URL. A JDBC database connection URL (uniform resource locator) provides
a way of identifying a database.
DriverManager.getConnection can take one argument besides a database connection
URL, a Properties object. You can use the Properties object to set database connection
URL attributes.
You can also supply strings representing user names and passwords. When they
are supplied, Derby checks whether they are valid for the current system if user