Skip to content

Oracle JDBC OCI connections

This article explains how to connect to an Oracle database using JDBC OCI (Type II). This method uses DBeaver's Generic driver by default, and Oracle-specific functionality depends on selecting the Oracle driver type.

Info

For information on Oracle Thin driver connection methods, see Configure Oracle connections.

Prerequisites

JDBC OCI connections require Oracle Instant Client on your local machine. The Instant Client and JDBC driver versions must match. DBeaver currently uses version 12.2.0.1 by default, so use version 12.2.0.1 of the Instant Client.

Extract or mount the Instant Client package for your operating system, and place the files in a folder of your choice. This article refers to that folder as ORA_HOME. Append ORA_HOME to the PATH variable and restart DBeaver before proceeding.

Configuration

  1. Prepare a tnsnames.ora file

    • If you don't have a tnsnames.ora file, create one:

      • Open a text editor.
      • Add your Oracle database connection details. These typically include the network alias, a connection description, and address parameters such as the hostname and port number.

        Example

        MYDB =
         (DESCRIPTION =
             (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.example.com)(PORT = 1521))
             (CONNECT_DATA =
               (SERVER = DEDICATED)
               (SERVICE_NAME = mydbservice.example.com)
             )
         )
        
      • Save the file as tnsnames.ora.

  2. Place the new or existing tnsnames.ora file in the ORA_HOME/network/admin directory.

  3. Configure the driver in DBeaver:

    • In DBeaver, go to Window -> Driver Manager -> New to open the Create new driver dialog.
    • On the Settings tab:

      • Enter your preferred Driver name.
      • Set Class Name to oracle.jdbc.OracleDriver.
      • Set URL Template to jdbc:oracle:oci:@tnsAlias, where tnsAlias is an alias from your tnsnames.ora file.
      • Set Driver Type to Generic.

    Tip

    The Generic driver type is recommended for broader compatibility, but it isn't required. You can select the Oracle driver type to access Oracle-specific features. However, a non-generic driver might cause unexpected errors with some JDBC functionality.

  4. Add Maven artifacts in DBeaver:

    • On the Libraries tab, click Add Artifact.
    • Paste the following XML into the text field.
    <dependencies>
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>12.2.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.nls</groupId>
            <artifactId>orai18n</artifactId>
            <version>12.2.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.xml</groupId>
            <artifactId>xdb6</artifactId>
            <version>12.2.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.xml</groupId>
            <artifactId>xmlparserv2</artifactId>
            <version>12.2.0.1</version>
        </dependency>
    </dependencies>
    

    Note

    Replace the artifact versions if you use a different version of the Instant Client.

  5. Configure driver properties:

    • Go to the Driver properties tab.
    • Right-click and choose Add new property.
    • Set the property name to protocol (without quotes).
    • Set the Value to oci (without quotes).
  6. Close the Driver Manager after you configure the properties.

  7. Create a connection in DBeaver using the driver you configured.