This topic describes how to install and load the OceanBase Connector/J driver and perform connection tests. Before the installation, make sure that the prerequisites are met.
Prerequisites
Before you install OceanBase Connector/J, set up the basic database development environment, and make sure that the Java environment on your computer is JDK 8.
You have obtained the installation package of the OceanBase Connector/J driver from OceanBase Technical Support.
Load the installation package
Place the JAR installation package of OceanBase Connector/J in a local directory. Use cmd to import the JAR package and then perform the following connection tests.
Compile the Java file
HelloWorld.javaand load OceanBase Connector/J.public class HelloWorld { public static void main(String[] args) { try { Class.forName("com.oceanbase.jdbc.Driver"); } catch (Throwable e) { e.printStackTrace(); } } }Run the following command to compile the Java sample file:
javac -cp target/oceanbase-client-{version}.jar HelloWorld.javaNote
You can change the compilation path as needed.
Run the following command to run the Java sample file:
java -cp .:target/oceanbase-client-{version}.jar HelloWorld
If all the preceding steps are performed and no error is returned, the JAR package of the OceanBase Connector/J driver is correctly loaded.