apache > db
Apache DB Project
Font size:      

The Derby Database Connection URL Attributes

The Derby Database Connection URL Attributes

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 "Database Connection URL Attributes".

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.

Connection conn = DriverManager.getConnection(
 -- setting an attribute in a Properties object 
Properties p = new Properties();
p.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");

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.)

Previous Page
Next Page
Table of Contents