DriverPropertyInfo array example

The following code shows how to use a DriverPropertyInfo array.

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; for example,
        // 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);