apache > db
Apache DB Project
Font size:      

The DriverPropertyInfo Array

The DriverPropertyInfo Array

When a non-zero-length array is returned by getPropertyInfo, each element is a DriverPropertyInfo object representing a connection URL attribute that has not already been specified. Only those that make sense in the current context are returned.

This DriverPropertyInfo object contains:

  • name of the attribute
  • description
  • current value

    If an attribute has a default value, this is set in the value field of DriverPropertyInfo, even if the attribute has not been set in the connection URL or the Properties object. If the attribute does not have a default value and it is not set in the URL or the Properties object, its value will be null.

  • list of choices
  • whether required for a connection request

Several fields in a DriverPropertyInfo object are allowed to be null.


Here is some example code:

import java.sql.*;
import java.util.Properties;
// start with the least amount of information
// to see the full list of choices
// we could also enter with a URL and Properties
// provided by a user.
String url = "jdbc:derby:";
Properties info = new Properties();
Driver cDriver = DriverManager.getDriver(url);
for (;;)
        DriverPropertyInfo[] attributes = cDriver.getPropertyInfo(
            url, info);
        // zero length means a connection attempt can be made
        if (attributes.length == 0)
        // insert code here to process the array, e.g.,
        // display all options in a GUI and allow the user to
        // pick and then set the attributes in info or URL.
// try the connection
Connection conn = DriverManager.getConnection(url, info);

Previous Page
Next Page
Table of Contents