Enabling an Application to Unlock a Branded Driver
- Last Updated: November 18, 2020
- 2 minute read
Note: For the Autonomous REST Connector: If your driver is locked to an API,
you do not need to unlock the branded driver as described in this section.
To unlock
a branded driver, the application must cast the returned connection object to an
ExtEmbeddedConnection object after calling Driver.connect(), DriverManager.getConnection(),
PooledConnection.getConnection(), or DataSource.getConnection(). Next, the application must
call the unlock method while passing the case-sensitive password specified during the branding
process. When you unlock a branded driver, you also unlock DataDirect Spy for JDBC, built-in functionality that allows you to track JDBC calls made by the driver on behalf of the application. For more information about using DataDirect Spy, refer to your product user's guide.
The following code examples show how to unlock the drivers using connection
URLs and data sources. The package prefix used in these examples is com.xyzcompany.xyzdivision the subprotocol prefix used is xyzcompany. Your application code must use the package prefix and subprotocol
prefix specified when the drivers were branded.
Unlocking a URL Connection
import com.ddtek.jdbc.extensions.ExtEmbeddedConnection;
...
String url = "jdbc:xyzcompany:mongodb://MyServer:27017;USER=sa;PASSWORD=xxx";
Class.forName ("com.xyzcompany.xyzdivision.jdbc.mongodb.MongoDBDriver");
Connection con = DriverManager.getConnection (url);
// ExtEmbeddedConnection is a DataDirect-specific interface
if (con instanceof ExtEmbeddedConnection) {
ExtEmbeddedConnection embeddedCon = (ExtEmbeddedConnection)con;
boolean unlocked = embeddedCon.unlock("xxx"); // "xxx" is the password
}
Unlocking a DataSource Connection
import com.ddtek.jdbc.extensions.ExtEmbeddedConnection;
...
// Create a DataSource object
MongoDBDataSource ds = new com.xyzcompany.xyzdivision.jdbcx.mongodb.MongoDBDataSource();
// Set the DataSource properties
...
// DataSource may be persisted to JNDI as usual or used directly
...
Connection con = ds.getConnection();
// ExtEmbeddedConnection is a DataDirect-specific interface
if (con instanceof ExtEmbeddedConnection) {
ExtEmbeddedConnection embeddedCon = (ExtEmbeddedConnection)con;
boolean unlocked = embeddedCon.unlock("xxx"); // "xxx" is the password
}