In the previous article, we talked about ODBC and connecting from C#. And now, let's look at JDBC and Java. The InterSystems JDBC driver is the recommended, high-performance way to integrate your Java applications.
Here is a step-by-step guide to getting your Java application connected to an IRIS instance using the JDBC driver.
Step 1: Obtain and Include the InterSystems IRIS JDBC Driver
Unlike ODBC drivers, which are often installed system-wide, JDBC drivers are typically distributed as JAR files that must be included in your Java project's classpath.
If InterSystems IRIS is installed on your local machine or another you have access to, you can find the file in install-dir/dev/java/lib/ or similar, where install-dir is the installation directory for the instance. Conversely, you can download the jar file from Driver packages page.
Or as suggested by @Dmitry Maslennikov in the comments, use the maven central repository for Maven:
<dependency>
<groupId>com.intersystems</groupId>
<artifactId>intersystems-jdbc</artifactId>
<version>3.10.5</version>
</dependency>
or for Gradle:
implementation("com.intersystems:intersystems-jdbc:3.10.5")
Include the jar file in Project:
- Maven/Gradle: If you use a build tool, the simplest method is to add the InterSystems JDBC driver as a dependency in your
pom.xml or build.gradle file. This automatically downloads and manages the JAR.
- Manual: For simple projects, you must place the JAR file in a project directory (e.g.,
/lib) and explicitly add it to your classpath when compiling and running.