This topic describes how to install and load OceanBase Connector/J and perform a connection test. Before the installation, make sure that the prerequisites are met.
Prerequisites
You have set up the basic database development environment and made sure that the Java environment on your computer is JDK 8, before you install OceanBase Connector/J.
You have obtained the installation package of OceanBase Connector/J.
Note
You can download the installation package of OceanBase Connector/J in the Drivers and Middleware section on the home page of the OceanBase Download Center. If you cannot find an installation package of the corresponding version, contact 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 test:
Create the sample Java file
HelloWorld.javaand load the driver class.public class HelloWorld { public static void main(String[] args) { try { Class.forName("com.oceanbase.jdbc.Driver"); } catch (Throwable e) { e.printStackTrace(); } } }Compile the sample Java file.
javac -cp target/oceanbase-client-{version}.jar HelloWorld.javaNote
You can change the compilation path as needed.
Run the sample Java file.
java -cp .:target/oceanbase-client-{version}.jar HelloWorld
If all the preceding steps are completed with no error message returned, the JAR package of OceanBase Connector/J has been correctly loaded.