Specify Connection Properties
When you use the DriverManager.getConnection() method to create a connection, HCL OneDB™ JDBC Driver reads HCL OneDB properties only from the name-value pairs in the connection database URL or from a connection property list. The driver does not consult the user's environment for any properties.
To specify HCL OneDB properties in the name-value pairs of the connection database URL, see Format of database URLs.
To specify HCL OneDB properties via a property list, use the java.util.Properties class to build the list of properties. The list of properties might include HCL OneDB properties, such as OPTOFC, as well as USER and PASSWORD.
After you have built the property list, pass it to the DriverManager.getConnection() method as a second parameter. You still need to include a database URL as the first parameter, although in this case you do not need to include the list of properties in the URL.
The following code shows how to use the java.util.Properties class to set connection
properties. It first uses the Properties.put() method to set the
environment variable OPTOFC to 1
in the connection
property list; then it connects to the database.
The DriverManager.getConnection() method in this example takes two parameters: the database URL and the property list. The example creates a connection similar to the example given in The DriverManager.getConnection() method.
jdbc:onedb://myhost:1533; USER=rdtest;PASSWORD=test
try { Properties pr = new Properties(); pr.put("OPTOFC","1"); conn = DriverManager.getConnection(newUrl, pr); } catch (SQLException e) { System.out.println("ERROR: failed to connect!"); e.printStackTrace(); }