JDBC Driver

This section describes the JDBC driver provided by Exasol to connect third party applications to Exasol.

System Requirements

JRE Requirement

The JDBC driver requires a Java runtime environment (version 5.0 or later). You can use the driver on any platform with JRE version 7 or later.

Tested Systems

The driver has been tested on the following systems using the specified Java version with the latest available updates.

  • Windows 10 (64-bit)

    • Java 1.8.0

    • Java 11.0.11

    • Java 17.0.2
      For Windows systems, Microsoft .NET Framework 4.0 Client Profile™ should be installed on your system. There is an automatic installation wizard for it.

  • Linux (64-bit)

    • Red Hat / CentOS 7, OpenJDK JVM 1.8.0

    • Red Hat / CentOS 8, OpenJDK JVM 1.8.0

    • OpenSUSE Leap 15.2, OpenJDK JVM 1.8.0

    • Debian 10, OpenJDK JVM 11.0.12

    • Ubuntu 18.04 LTS, OpenJDK JVM 11.0.13

    • Ubuntu 20.04 LTS, OpenJDK JVM 11.0.13

  • macOS (64-bit)

    • macOS Mojave (10.14), JVM 16.0.1

    • macOS Catalina (10.15), JVM 16.0.1

    • macOS Big Sur (11.6.1), JVM 1.8.0

    • macOS Monterey (12.0.1), JVM 1.8.0

  • Free BSD (64-bit)

    • Free BSD 12.2, OpenJDK JVM 1.8.0

Download JDBC Driver

  1. Download the driver for your Exasol version and operating system from the Exasol Download Portal.

    There are no specific drivers for Exasol 8. The latest drivers for Exasol 7.1.x are fully compatible with Exasol 8.

  2. Run the downloaded executable file and follow the setup wizard to complete the installation.

Installing JDBC Driver

On Windows

The driver is installed as a .jar archive in the installation directory.

On Linux/Unix

The driver is included in the download. Depending on the application, the archive must be added to the search path for the Java classes (CLASSPATH).

All classes of the JDBC driver belong to the Java com.exasol.jdbc package. The main class of the driver is com.exasol.jdbc.EXADriver

License

Each driver package includes the latest version of the license for the driver. The license allows you to bundle the driver with third-party software, for example when creating plugins for a BI tool. For more details, refer to the license file which is located in the folder where the driver was installed.

Integrating JDBC Driver using Maven

The JDBC driver is also available on Maven Central (https://search.maven.org/artifact/com.exasol/exasol-jdbc). Add the following dependency to the build configuration of your project (for example, pom.xml for Maven).

Replace the version number in this example with the latest supported driver version.

<dependencies>
    <dependency>
        <groupId>com.exasol</groupId>
        <artifactId>exasol-jdbc</artifactId>
        <version>7.0.0</version>
    </dependency>
</dependencies>

Exasol URL

The JDBC Driver uses the following URL structure for Exasol:

jdbc:exa:<host>:<port>[;<prop_1>=<value_1>]...[;<prop_n>=<value_n>]

The following table explains the elements of the URL structure.

Element Details
jdbc:exa This prefix is necessary for the driver manager.
<host>:<port>

Defines the servers and the port of the Exasol cluster.

Servers can be specified as a single hostname or IP address, as multiple hostnames or IP addresses specified as a range using the format first_host..last_host:port, or as a comma-separated list of host-port pairs. When opening a connection, the driver will randomly choose an address from the specified range. If the connection fails, the driver will continue to try all other possible addresses in the range.

Examples:

  • myhost:8563

  • myhost1,myhost2:8563

  • myhost1..4:8563

  • 192.168.6.11..14:8563

  • 192.168.6.11:8563,192.168.6.12:8563,192.168.6.13:8563,192.168.6.14:8563

You can also specify a file that contains a list of server definitions, for example: //c:\mycluster.txt. The two forward slashes indicate that the parameter value is a file path.

<prop_i=value_i>

The port can be followed by an optional semicolon-separated list of properties that should be set during login. These properties correspond with the supported driver properties that are described in the following section.

The values of properties within the URL can only consist of alphanumeric characters.

Example from a Java program

import java.sql.*;
import com.exasol.jdbc.*;

public class jdbcsample
{
    public static void main(String[] args)
    {
        try { Class.forName("com.exasol.jdbc.EXADriver");
    } catch (ClassNotFoundException e) { 
            e.printStackTrace();
    }
    Connection con=null
    Statement stmt=null
    try {
        con = DriverManager.getConnection( 
            "jdbc:exa:192.168.6.11..14:8563;schema=SYS",
            "sys", 
            "exasol"
            );
        stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM CAT")
        System.out.println("Schema SYS contains:")
        while(rs.next())
        {
            String str1 = rs.getString("TABLE_NAME")
            String str2 = rs.getString("TABLE_TYPE")
            System.out.println(str1 + ", " + str2);
        }
    } catch (SQLException e) { 
        e.printStackTrace();
    } finally {
        try {stmt.close();} catch (Exception e) {e.printStackTrace();} 
        try {con.close();} catch (Exception e) {e.printStackTrace();}
        }
    }
}

The code sample above builds a JDBC connection to an Exasol database on servers in IP address range 192.168.6.11 to 192.168.6.14 using port 8563. User sys with the password exasol is logged in, and the schema sys is opened. After that, all tables in this schema are shown.

Schema SYS contains: 
EXA_SQL_KEYWORDS, TABLE 
DUAL, TABLE 
EXA_PARAMETERS, TABLE
...

Supported Driver Standards

The JDBC driver supports JDBC 4.1 Core API. Detailed information about the supported interfaces are provided in the API Reference which you can find in the html folder of the driver installation directory. If you want to learn more about JDBC, see JDBC Basics.

The standard includes the following:

  • Access to the driver through the DriverManager API and configuration of the driver using the DriverPropertyInfo interface.
  • Direct execution of SQL statements as a prepared statement and in batch mode.
  • Support of more than one open ResultSet.
  • Support of the DatabaseMetaData and ResultSetMetaData metadata APIs.

The following features are not supported:

  • Savepoints
  • User-defined data types and the types Blob, Clob, Array, and Ref.
  • Stored procedures
  • Read-only connections
  • The API ParameterMetaData

If the rowcount of a query exceeds 2147483647 (231-1), the JDBC driver will return the value 2147483647. This is because of the 32-bit limitation for this return value defined by the JDBC standard.

Supported Driver Properties

The following table describes all properties that can be transferred to the JDBC driver through the URL. Properties that are not listed in the table are not supported in this version of Exasol.

Property names are case sensitive.

Property Value Description
autocommit

0=off, 1=on

Switches autocommit on or off.

Default: 1

clientname

string

Defines the name of the client sent to the server.

Default: "Generic JDBC client"

clientversion

string

Defines the version of the client sent to the server.

Default: empty ("")

connectionPoolSize numeric, >=0

Changes the maximum size of the connection pool (number of connections). You can change this value only once in the driver instance.

Default: 64

Valid values: 0<connectionPoolSize<8192

connecttimeout

numeric, >=0

Maximum time in milliseconds that the driver waits to establish a TCP connection to a server. This timeout is used to limit the login time especially in case of a large cluster with multiple reserve nodes.

Default: 2000

debug

0=off, 1=on

Switches on the driver's log function. The driver then writes a log file named jdbc_timestamp.log for each established connection.

These files contain information on the called driver methods and the progress of the JDBC connection. It can assist the Exasol Support in the diagnosis of problems.

Due to performance reasons the logging should not be used in a productive system

Default: 0

encryption

0=off, 1=on

Switches automatic encryption on or off.

Default: 1

feedbackinterval integer

During a query the server sends feedback to the client at set intervals. This feedback does the following:

  • Signals that the server is still there and executing the client command

  • Prevents the connection from being cut by the networks for inactivity

  • Checks whether a command is canceled

Default: 30 seconds

Setting a very high feedback interval value may cause a long lag time before a command is canceled.

fetchsize

numeric, >0

Amount of data in kB which should be obtained by Exasol during a fetch. The JVM can run out of memory if the value is too high.

Default: 2000

The fetch size can also be set by using the function setFetchSize().

kerberoshostname

string

Host name of the Kerberos service. If nothing is specified, the host name of the connections string will be used as default
kerberosservicename

string

Principal name of the Kerberos service. If nothing is specified, the name "exasol" will be used as default.
logdir

string

Defines the directory where the JDBC debug log files should be written to (in debug mode).

Example: jdbc:exa:192.168.6.11..14:8563;debug=1;logdir=/tmp/my folder/;schema=sys

Default is the application's current directory, which is not always transparent. That is why you should always set the log directory in debug mode.

logintimeout

numeric, >=0

The maximum time in milliseconds that the driver will wait to establish a connection. This timeout is required to limit the overall login time, especially in the case of a large cluster with several reserve nodes.

Default: 0 (infinite)

logintype

1 or SSPI,

2 or GSSAPI

Default on Windows systems is 1 or SSPI

Default on non-Windows systems is 2 or GSSAPI

querytimeout

numeric, >=0

Defines the time in seconds for a statement to run before it is automatically aborted.

Default: 0 (infinite)

schema

string

Name of the schema that should be opened after login. If the schema cannot be opened, the login fails with a java.sql.SQLException.

Default: no schema to open

snapshottransactions

0=off, 1=on

Changes the snapshottransaction setting in the session.

Possible values:

If not set, the default in the session is used.

superconnection

Y=on, N=off

Enables the user to execute queries even if the limit for active sessions (executing a query) has been reached.

Note:

  • Only the SYS user can set the parameter.
  • superconnection should only be used in case of significant performance problems where it is impossible to log in and execute queries within a reasonable time. By that parameter you can analyze the system and kill certain processes which cause the problem.

Default: database default

worker

0=off, 1=on

The sub-connections for parallel read and insert have this flag switched on.

Details and examples are available in this Exasol Knowledge Base article.

Default: 0

workertoken

numeric, >=0

Is necessary to establish parallel sub-connections.

Default: 0

Best Practices

Objective Details

Memory of JVM

When operating on big tables, you can get problems if the specified memory for the JVM is not big enough.

Reading big data volumes

Through the parameter fetchsize you can determine the data volume that should be fetched from the database per communication round. If this value is too low, the data transfer may take longer to complete. If this value is too high, the JVM may run out of memory. The recommended fetch size is 1000 to 2000.

Inserting data into the database

Instead of using single insert statements like INSERT INTO t VALUES 1, 2, ..., use the more efficient interface of prepared statements and their parameters. Prepared statements achieve optimal performance when using parameter sets between 500 kB and 20 MB.

Insert the data using the native data types. For example, for the number 1234 use SQL_C_SLONG (integer) instead of SQL_CHAR.

Unused resources

Unused resources should be freed immediately. For example, Prepared Statements through close().

Connection servers

Do not specify an unnecessary wide range of IP addresses. Since the addresses in the specified range are randomly tried until a successful connection is made, the connect operation can take a long time.