OpenLink ODBC-JDBC Lite Bridge with Support for Java 8+
A new ODBC-JDBC Lite Bridge Driver for macOS has been released and is available for evaluation download here. This version includes support for the latest editions of the Java Virtual Machine, including Java 15 and later, as of the time of this post.
General Pre-Installation Notes
License File Check
Ensure that you have downloaded your free evaluation or purchased license files to your local machine. Once downloaded, copy them to the appropriate license folder for your operating system:
-
macOS:
/Library/Application Support/OpenLink/Licenses/
. -
Windows:
C:\Program Files\OpenLink Software\UDA\bin
for 64-Bit Editions of Windows orC:\Program Files (x86)\OpenLink Software\UDA\bin\
for 32-Bit Editions of Windows. -
Linux:
/opt/openlink/bin/
or/etc/oplmgr/
folders, subject to your privileges. Either way, use the$OPL_LICENSE_DIR
environment variable to inform the OpenLink License Manager about license file location.
Make sure to replace any existing files if you’re upgrading or updating a license.
Java Runtime Environment Check
Ensure a Java Runtime Environment (JVM) is installed and verified before installing the Lite Edition ODBC-JDBC Bridge. The installer checks for the presence of a Java Runtime and will not proceed without it. This is necessary for the Driver’s rpath
variable to be correctly set to the location of the required jvm
library.
JDBC Driver Name Awarness
For instance, here are the names of OpenLink ODBC-JDBC Bridge, Virtuoso, and Oracle’s native JDBC drivers:
- OpenLink ODBC-JDBC Bridge –
openlink.jdbc4.Driver
- Virtuoso JDBC Driver –
virtuoso.jdbc4.Driver
- Oracle JDBC Driver –
oracle.jdbc.OracleDriver
JDBC Driver JAR File Locations
For system-wide access to JDBC drivers, copy their JAR files
from their installation location to the /Library/Java/Extensions/
folder.
CLASSPATH Setup
Operating System Launch Time
You achieve this using the macOS launchctl
command for system-wide access to JDBC Drivers by executing the following command:
launchctl setenv CLASSPATH /path/to/driver1.jar:/path/to/driver2.jar:/path/to/driverN.jar
You can verify that these settings have taken effect by executing the following command:
launchctl getenv CLASSPATH
Runtime
In situations where you don’t want to reboot your OS, you can set your CLASSPATH environment variable by executing the following command:
export CLASSPATH=$CLASSPATH:/path/to/driver1.jar:/path/to/driver2.jar:/path/to/driverN.jar
You can verify that these settings have taken effect by executing the following command:
echo $CLASSPATH
As Part of JDBC Application Invocation
java -cp /path/to/driver.jar:other_classpath_entries YourJDBCApp
or
java -cp $CLASSPATH YourJDBCApp
Usage Examples
-
for the OpenLink JDBC-to-ODBC Bridge Driver:
export CLASSPATH=$CLASSPATH:/Libary/Java/Extensions/opljdbc4_2.jar
-
for the JDBC-to-ODBC Bridge and Virtuoso JDBC Drivers:
export CLASSPATH=$CLASSPATH:/Libary/Java/Extensions/opljdbc4_2.jar:/Library/Java/Extensions/virtjdbc4.jar
-
for the JDBC-to-ODBC Bridge, Virtuoso JDBC, Oracle Drivers:
export CLASSPATH=$CLASSPATH:/Libary/Java/Extensions/opljdbc4_2.jar:/Library/Java/Extensions/virtjdbc4.jar:/Library/Java/Extensions/ojdbc17.jar:/Library/Java/Extensions/jdbc-15.0.0.1.1.jar
-
for the JDBC-to-ODBC Bridge, Virtuoso JDBC, Oracle, and Informix Drivers:
export CLASSPATH=$CLASSPATH:/Libary/Java/Extensions/opljdbc4_2.jar:/Library/Java/Extensions/virtjdbc4.jar:/Library/Java/Extensions/ojdbc17.jar:/Library/Java/Extensions/jdbc-15.0.0.1.1.jar
Verifying JDBC Driver Installations to be used by the ODBC-JDBC Bridge
Virtuoso JDBC Driver
Sample Application Code
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Enumeration;
import java.sql.Driver;
public class VirtuosoJDBCTest {
public static void main(String[] args) {
String jdbcUrl = "jdbc:virtuoso://localhost:1111/charset=UTF-8/";
String username = "dba";
String password = "dba";
try {
// List all registered JDBC drivers
System.out.println("Registered JDBC Drivers:");
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
System.out.println("Driver: " + driver.getClass().getName() +
", version: " + driver.getMajorVersion() +
"." + driver.getMinorVersion());
}
// Get connection information
System.out.println("\nConnecting to database...");
Connection conn = DriverManager.getConnection(jdbcUrl, username, password);
// Get metadata information
DatabaseMetaData metaData = conn.getMetaData();
// Get the class name of the JDBC driver that created this connection
String driverClassName = metaData.getDriverName();
// Get the actual Driver class that's handling this connection
Driver connectionDriver = DriverManager.getDriver(jdbcUrl);
String actualDriverClass = connectionDriver.getClass().getName();
System.out.println("JDBC Driver Name: " + driverClassName);
System.out.println("JDBC Driver Class: " + actualDriverClass);
System.out.println("JDBC Driver Version: " + metaData.getDriverVersion());
System.out.println("JDBC Spec Version: " + metaData.getJDBCMajorVersion() +
"." + metaData.getJDBCMinorVersion());
System.out.println("Database Product Name: " + metaData.getDatabaseProductName());
System.out.println("Database Product Version: " + metaData.getDatabaseProductVersion());
// Close connection
conn.close();
System.out.println("Connection closed.");
} catch (SQLException e) {
System.err.println("SQL Error: " + e.getMessage());
e.printStackTrace();
}
}
}
Run by peforming the following steps:
- Save the source code above to a file e.g.,
VirtuosoJDBCTest.java
- Compile the source code for Java Runtime use by running the command:
javac VirtuosoJDBCTest.java
- Execute the compiled code by running the command:
java VirtuosoJDBCTest
Oracle JDBC Driver
Sample Application Code
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Enumeration;
import java.sql.Driver;
public class OracleJDBCTest {
public static void main(String[] args) {
String jdbcUrl = "jdbc:oracle:thin:@54.172.89.18:1521:XE";
String username = "hr";
String password = "openlink";
try {
// List all registered JDBC drivers
System.out.println("Registered JDBC Drivers:");
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
System.out.println("Driver: " + driver.getClass().getName() +
", version: " + driver.getMajorVersion() +
"." + driver.getMinorVersion());
}
// Get connection information
System.out.println("\nConnecting to database...");
Connection conn = DriverManager.getConnection(jdbcUrl, username, password);
// Get metadata information
DatabaseMetaData metaData = conn.getMetaData();
// Get the class name of the JDBC driver that created this connection
String driverClassName = metaData.getDriverName();
// Get the actual Driver class that's handling this connection
Driver connectionDriver = DriverManager.getDriver(jdbcUrl);
String actualDriverClass = connectionDriver.getClass().getName();
System.out.println("JDBC Driver Name: " + driverClassName);
System.out.println("JDBC Driver Class: " + actualDriverClass);
System.out.println("JDBC Driver Version: " + metaData.getDriverVersion());
System.out.println("JDBC Spec Version: " + metaData.getJDBCMajorVersion() +
"." + metaData.getJDBCMinorVersion());
System.out.println("Database Product Name: " + metaData.getDatabaseProductName());
System.out.println("Database Product Version: " + metaData.getDatabaseProductVersion());
// Close connection
conn.close();
System.out.println("Connection closed.");
} catch (SQLException e) {
System.err.println("SQL Error: " + e.getMessage());
e.printStackTrace();
}
}
}
Run by peforming the following steps:
-
Save the source code above to a file e.g.,
OracleJDBCTest.java
-
Compile the source code for Java Runtime use by running the command:
javac OracleJDBCTest.java
-
Execute the compiled code by running the command:
java OracleJDBCTest
Informix JDBC Driver
Sample Application Code
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Enumeration;
import java.sql.Driver;
public class InformixJDBCTest {
public static void main(String[] args) {
String jdbcUrl = "jdbc:informix-sqli://54.172.89.18:27669/stores_demo:INFORMIXSERVER=ol_informix1410";
String username = "informix";
String password = "fitzroyinformix";
try {
// List all registered JDBC drivers
System.out.println("Registered JDBC Drivers:");
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
System.out.println("Driver: " + driver.getClass().getName() +
", version: " + driver.getMajorVersion() +
"." + driver.getMinorVersion());
}
// Get connection information
System.out.println("\nConnecting to database...");
Connection conn = DriverManager.getConnection(jdbcUrl, username, password);
// Get metadata information
DatabaseMetaData metaData = conn.getMetaData();
// Get the class name of the JDBC driver that created this connection
String driverClassName = metaData.getDriverName();
// Get the actual Driver class that's handling this connection
Driver connectionDriver = DriverManager.getDriver(jdbcUrl);
String actualDriverClass = connectionDriver.getClass().getName();
System.out.println("JDBC Driver Name: " + driverClassName);
System.out.println("JDBC Driver Class: " + actualDriverClass);
System.out.println("JDBC Driver Version: " + metaData.getDriverVersion());
System.out.println("JDBC Spec Version: " + metaData.getJDBCMajorVersion() +
"." + metaData.getJDBCMinorVersion());
System.out.println("Database Product Name: " + metaData.getDatabaseProductName());
System.out.println("Database Product Version: " + metaData.getDatabaseProductVersion());
// If using connection pooling, you would check pool status here
// System.out.println("Active Connections: " +
// System.out.println("Idle Connections: " +
// Close connection
conn.close();
System.out.println("Connection closed.");
} catch (SQLException e) {
System.err.println("SQL Error: " + e.getMessage());
e.printStackTrace();
}
}
}
Run by peforming the following steps:
-
Save the source code above to a file e.g.,
InformixJDBCTest.java
-
Compile the source code for Java Runtime use by running the command:
javac InformixJDBCTest.java
-
Execute the compiled code by running the command:
java InformixJDBCTest