background image
<< Derby database connection URL syntax | java.sql.Connection.setTransactionIsolation method >>

Attributes of the Derby database connection URL

<< Derby database connection URL syntax | java.sql.Connection.setTransactionIsolation method >>
Derby Reference Manual
305
Derby also supports the following SQL standard syntax to obtain a reference to the
current connection in a database-side JDBC routine:
jdbc:default:connection
Attributes of the Derby database connection URL
You can supply an optional list of attributes to a database connection URL. Derby
translates these attributes into properties, so you can also set attributes in a Properties
object passed to DriverManager.getConnection. (You cannot set those attributes
as system properties, only in an object passed to the DriverManager.getConnection
method.)
These attributes are specific to Derby and are listed in
Setting attributes for the database
connection URL
.
Attribute name/value pairs are converted into properties and added to the properties
provided in the connection call. If no properties are provided in the connection call, a
properties set is created that contains only the properties obtained from the database
connection URL.
import java.util.Properties;
Connection conn = DriverManager.getConnection(
"jdbc:derby:sampleDB;create=true");
/* setting an attribute in a Properties object */
Properties myProps = new Properties();
myProps.put("create", "true");
Connection conn = DriverManager.getConnection(
"jdbc:derby:sampleDB", myProps);
/* passing user name and password */
Connection conn = DriverManager.getConnection(
"jdbc:derby:sampleDB", "dba", "password");
Note: Attributes are not parsed for correctness. If you pass in an incorrect attribute
or corresponding value, it is simply ignored. (Derby does provide a tool for parsing the
correctness of attributes. For more information, see the Derby Tools and Utilities Guide.)
java.sql.Connection interface
A Derby Connection object is not garbage-collected until all other JDBC objects created
from that connection are explicitly closed or are themselves garbage-collected. Once the
connection is closed, no further JDBC requests can be made against objects created
from the connection. Do not explicitly close the Connection object until you no longer
need it for executing statements.
A session-severity or higher exception causes the connection to close and all other JDBC
objects against it to be closed. System-severity exceptions cause the Derby system to
shut down, which not only closes the connection but means that no new connections
should be created in the current JVM.
The following table describes features of Connection methods that are specific to Derby.
Table 120.
Implementation notes on Connection methods
Returns
Signature
Implementation Notes
PreparedStatement
prepareStatement(String sql, int []
columnIndexes)
Every column index in
the array must correlate