ODBC/JDBC Connector Guide

Kinetica provides a SQL interface through its ODBC & JDBC drivers, which run on Linux, Mac, & Windows. For details on the extent of SQL compliance, see the SQL section.

Connecting

KiSQL

KiSQL is a Kinetica JDBC-based SQL CLI client that is available on GitHub. Details can be found on the Kinetica SQL (KiSQL) page.

JDBC

JDBC connections require the Kinetica JDBC driver.

Acquire the JDBC client JAR, kinetica-jdbc-7.1.<X>.<Y>-jar-with-dependencies.jar, from either:

  • the JDBC Client Project on GitHub
  • under /opt/gpudb/connectors/jdbc on default Kinetica installations

The following is the general driver and connection information that should be used when configuring a client.

  • Driver: <point to the downloaded JAR file>

  • Connection String:

    Syntax
    1
    
    jdbc:kinetica:URL=http://<db.host>:9191;CombinePrepareAndExecute=1[[;<parameter>=<value>]*]
    
    Example
    1
    
    jdbc:kinetica:URL=http://kineticahost:9191;CombinePrepareAndExecute=1;RowsPerFetch=20000
    
  • Class Name: com.kinetica.jdbc.Driver

See ODBC/JDBC Configuration for additional configuration parameters.


Secure Connections

When connecting to a Kinetica instance over HTTPS, the connection string should reference the database's secure address.

Tip

See SSL Parameters for additional parameters that may be necessary to use when connecting over SSL.

Set the URL parameter on the JDBC connection string to use the HTTPS-enabled database endpoint.

Syntax
1
jdbc:kinetica:URL=https://<db.host>:<db.ssl-port>/gpudb-0;CombinePrepareAndExecute=1[[;<parameter>=<value>]*]
Example
1
jdbc:kinetica:URL=https://kineticahost:8082/gpudb-0;CombinePrepareAndExecute=1;RowsPerFetch=20000

Failover Connections

When connecting to a Kinetica instance with one or more failover clusters, the connection string should be updated to contain a comma-delimited list of head node addresses for all clusters. The URL of the primary cluster can also be specified.

Add a URL parameter to the JDBC connection string to contain all cluster head node addresses and add a PrimaryURL parameter designating the cluster that should be tried first.

Syntax
1
jdbc:kinetica:URL=http://<database1.host>:<database1.port>,...,http://<databaseN.host>:<databaseN.port>;PrimaryURL=http://<databaseX.host>:<databaseX:port>
Example
1
jdbc:kinetica:URL=http://kineticaA:9191,http://kineticaB:9191,http://kineticaC:9191;PrimaryURL=http://kineticaB:9191

ODBC

The ODBC Client must be installed for the environment in which it will be used. The following sections will detail how to install & configure the client in Windows.

Kinetica provides both a 32-bit & 64-bit Windows ODBC Client driver. The 32-bit version of Windows requires the 32-bit driver. The 64-bit version of Windows can use either the 32-bit or 64-bit driver, or both, as needs warrant. For instance, a user running 64-bit Windows and wanting to make ODBC connections to Kinetica from a 32-bit version of Excel will need the 32-bit driver. A user with the same OS using the 64-bit Tableau will need the 64-bit driver. A user wanting to use both will need both drivers.

  1. Download & install the ODBC Client for Windows following the instructions provided there

  2. Launch ODBC Data Source Administrator (64-bit or 32-bit, as needed)

  3. Click the System DSN tab

  4. Click the Add button to add a DSN

  5. Choose Kinetica ODBC Client, and click Finish

  6. Fill in the DSN Setup parameters (the following settings are examples - you may have to change some for your environment):

    • Description: Kinetica

    • URL:

      Syntax
      1
      
      http://<db.host>:9191;CombinePrepareAndExecute=1[[;<parameter>=<value>]*]
      
      Example
      1
      
      http://localhost:9191;CombinePrepareAndExecute=1;RowsPerFetch=20000
      
    • Leave User and Password blank

  7. Click OK

See ODBC/JDBC Configuration for additional configuration parameters.


Secure Connections

When connecting to a Kinetica instance over HTTPS, the connection string should reference the database's secure address.

Tip

See SSL Parameters for additional parameters that may be necessary to use when connecting over SSL.

Set the URL parameter to use the HTTPS-enabled database endpoint.

Syntax
1
https://<db.host>:<db.ssl-port>/gpudb-0;CombinePrepareAndExecute=1[[;<parameter>=<value>]*]
Example
1
https://localhost:8082/gpudb-0;CombinePrepareAndExecute=1;RowsPerFetch=20000

Failover Connections

When connecting to a Kinetica instance with one or more failover clusters, the connection string should be updated to contain a comma-delimited list of head node addresses for all clusters. The URL of the primary cluster can also be specified.

Modify the URL parameter to contain all cluster head node addresses and add a PrimaryURL parameter designating the cluster that should be tried first.

  • URL:

    Syntax
    1
    
    http://<database1.host>:<database1.port>,...,http://<databaseN.host>:<databaseN.port>
    
    Example
    1
    
    http://kineticaA:9191,http://kineticaB:9191,http://kineticaC:9191
    
  • PrimaryURL:

    Syntax
    1
    
    http://<databaseX.host>:<databaseX:port>
    
    Example
    1
    
    http://kineticaB:9191
    

Tableau

  1. Install the ODBC Client - see ODBC Installation above
  2. In Tableau, connect to Other Databases (ODBC)
    • DSN: Kinetica
    • Click Connect
    • Click Sign In
    • Database: KINETICA
    • Schema: <choose one>
      • To use the user's default schema, don't choose a schema (leave as Select Schema)
    • Pick your table

Note

Tableau may give a warning about not all features being supported by the ODBC driver; this should be able to be safely ignored for most applications.

Excel

  1. Install the ODBC Client - see ODBC Installation above
  2. In Excel, click the Data tab at the top
  3. Click the Get External Data > From Other Sources button, then click From Data Connection Wizard
  4. In the Connection Wizard, choose ODBC DSN and click Next >
  5. Select one of the ODBC data sources (i.e., DSNs) you created above (e.g., Kinetica), and click Next >
  6. Continue with the wizard to create a link to all the tables or a specific table, and save an ODC file, etc.
  7. Click the Finish button

To read in data using the ODC file created above:

  1. In Excel, click the Data tab at the top
  2. Click Get External Data > Existing Connections
  3. Choose the ODC file you created above, and click Open
  4. Select a Table to import
  5. Select where you want the data to appear, and click the OK button

DBeaver

  1. Acquire the JDBC Driver
  2. Download & install DBeaver
  3. Configure DBeaver with the Kinetica JDBC driver
    • On the Database menu, select Driver Manager
    • Click New to create a new driver connection
    • Complete the driver configuration page:
      • Driver Name: Kinetica
      • Class Name: com.kinetica.jdbc.Driver
      • Click the Libraries tab; then click Add File and select the downloaded kinetica-jdbc-7.1.<X>.<Y>-jar-with-dependencies.jar
      • Click OK
    • Click Close to exit Driver Manager
  • Configure a connection:

    • On the File menu, select New

    • Ensure that Database Connection is selected and click Next >

    • Select Kinetica and click Next >

    • Complete the connection configuration page:

      • JDBC URL:

        Syntax
        1
        
        jdbc:kinetica:URL=http://<db.host>:9191;CombinePrepareAndExecute=1[[;<parameter>=<value>]*]
        
        Example
        1
        
        jdbc:kinetica:URL=http://kineticahost:9191;CombinePrepareAndExecute=1;RowsPerFetch=20000
        
      • Username: name of connecting user (admin for database administrator connection)

      • Password: password for connecting user

      • Click Connection Details and enter a Connection name; then, click Back

    • Click Finish to complete the connection configuration

Other JDBC Clients

For other clients, see JDBC for the general setup to use.

Tip

There are many Java SQL clients available; a list can be found here.

ODBC/JDBC Configuration

Unless noted, the configuration parameters are the same for ODBC & JDBC, though the locations of the configurations are not.

  • Windows ODBC - Settings are stored in the registry in HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBC.INI\\\<DSN NAME\>

  • JDBC - Settings are passed on the connection string, separated by semicolons; e.g.:

    Syntax
    1
    
    jdbc:kinetica:URL=http://<db.host>:9191;CombinePrepareAndExecute=1[[;<parameter>=<value>]*]
    
    Example
    1
    
    jdbc:kinetica:URL=http://kineticahost:9191;CombinePrepareAndExecute=1;RowsPerFetch=20000
    

Some settings of note follow.

Standard Parameters

Config Parameter Default Value Description
URL http://127.0.0.1:9191 URL of Kinetica database server to connect to--this may be a comma-delimited list of multiple clusters in an HA configuration
Schema <user default> Default schema to use within the session
UID   User ID for database connection (blank to use default credentials)
PWD  

Password for database connection (blank to use default credentials)

Note

If the password contains special characters, they must be encoded using URL-style encoding; e.g., encode a semicolon as %3B

Timeout 0 Minutes to wait for a response from the database; 0 for no timeout
CombinePrepareAndExecute 0

Whether or not to combine the JDBC/ODBC prepare and execute phases, when appropriate. This can improve the performance of static queries (those that lack parameterized values).

  • 0 = Don't combine prepare and execute phases
  • 1 = Combine prepare and execute phases

Tip

This parameter should be set to 1 whenever possible. Some JDBC clients may return odd errors when this is active, however; and may need to be set to 0 to function properly.

This parameter is not needed when using KiSQL.

PrimaryURL   URL of a cluster to always attempt to go to first (if URL is a list)

Server Override Parameters

The following are optional parameters that could be used to override the default settings, which are set by the server. See the Configuration Reference for more information on configuring the SQL Engine server-side.

Config Parameter Description
CostBasedOptimization

Whether or not to use the cost-based optimizer

  • 0 = Disable cost-based optimizations
  • 1 = Enable cost-based optimizations
DistributedJoins

Whether or not to process operations that would require resharding of data to complete successfully

  • 0 = Disable distributed operations, failing any queries requiring resharding of data to succeed
  • 1 = Enable distributed operations, resharding data to meet sharding requirements, if necessary
LateMaterialization

Whether or not to avoid materializing intermediary result sets when processing a complex query

  • 0 = Materialize intermediary result sets
  • 1 = Avoid materializing intermediary result sets
PagingTableTtl

TTL for the result set paging table, in minutes; other possible values:

  • -1 = no TTL (temp sets will not expire)
  • 0 = expire immediately (at next clean-up interval)
ParallelExecution

Whether or not to execute independent portions of a query in parallel

  • 0 = Execute each component of a query in series, regardless of intra-query dependencies
  • 1 = Enable parallel execution of independent portions of a query
PlanCache

Whether or not to cache query plans, as derived by the rule-based/cost-based optimizer

  • 0 = Disable caching of query plans
  • 1 = Enable caching of query plans
ResultsCaching

Whether or not to cache result sets, which happens automatically for certain queries that have only materialized views as sources

  • 0 = Disable caching of result sets
  • 1 = Enable caching of result sets
RuleBasedOptimization

Whether or not to use the rule-based optimizer

  • 0 = Disable rule-based optimizations
  • 1 = Enable rule-based optimizations
SsqOptimization

Whether or not to use scalar subquery optimizations, in which non-correlated single-value-returning subqueries will be evaluated first and then those result constants will be used in the remainder of the query processing

  • 0 = Disable scalar subquery optimizations
  • 1 = Enable scalar subquery optimizations
TTL

TTL for temporary result tables, in minutes. Other possible values:

  • -2 = use server's default TTL
  • -1 = no TTL (temp sets will not expire)
  • 0 = expire immediately (at next clean-up interval)
UpdateOnExistingPk

Whether or not to use an upsert policy for record collision when inserting into a table with a primary key; if the specified table does not have a primary key, then this parameter is ignored

  • 0 = Discard any record being inserted whose primary key matches that of an existing record
  • 1 = Replace any existing record with the record being inserted, when the primary keys match
ValidateChange

When issuing an ALTER TABLE that changes column types/sizes, verify that the column data can be contained losslessly in the target column type/size. If true, fail the request if the data will not fit; if false, truncate the data to fit.

  • 0 = Truncate any column data that won't fit into the new type size on a column change request
  • 1 = Validate any column change and fail the request if column data is too large/long for the new type/size

Client Parameters

The following optional parameters may be used to change the ODBC/JDBC Client behavior.

Config Parameter Default Value Description
CombineResults 0

How to return the results of multiple DDL statements in a single Execute call (JDBC only)

  • 0 = Return individual result counts for each DDL statement
  • 1 = Combine result counts into a single result
DisableAutoDiscovery 0

Whether to query the server to find related clusters (JDBC only)

  • 0 = Perform standard auto-discovery
  • 1 = Do not perform auto-discovery
DisableFailover 0

Whether to attempt operations on another cluster after a failure (JDBC only)

  • 0 = Do attempt to perform the operation on another cluster after a failure, if another cluster is configured
  • 1 = Do not attempt to perform the operation on another cluster after a failure
DisableMultiheadInsert 0

Whether to use distributed ingest for supported INSERT statements (JDBC only)

  • 0 = Use high-performance distributed ingest when possible, unless KI_HINT_SERVER_SIDE_INSERT is specified
  • 1 = Use normal INSERT processing
FakeTransactions 0

Whether to throw exceptions when the client attempts to start or rollback a transaction (JDBC only); useful for 3rd party tools, such as JPA or Hibernate, that expect transaction support

  • 0 = Throw an exception when client attempts to control a transaction
  • 1 = Do not throw an exception, but still ignore, if client attempts to control a transaction

Important

Kinetica does not support transactions; this will only affect how the JDBC driver responds to transactional requests it can't fulfill.

Limit -1 Limit number of records returned for each query issued; -1 for no limit, i.e., all records will be returned for each query
LogLevel 0

Controls the amount of debug logging done by driver

  • 0 = Off
  • 1 = Fatal
  • 2 = Error
  • 3 = Warning
  • 4 = Info
  • 5 = Debug
  • 6 = Trace
NoSync 0

Whether to force all HA operations to be performed asynchronously (JDBC only)

  • 0 = Perform operations normally, synchronously and asynchronously, as configured
  • 1 = Force all HA operations to be performed asynchronously
ReadOnly 0

Whether the driver will report itself as being in a read-only mode, even though it is in full-access mode; useful for 3rd party tools that expect and enforce a read-only connection

  • 0 = Driver will not report itself as being in a read-only mode when queried via the JDBC/ODBC API
  • 1 = Driver will report itself as being in a read-only mode, even though this is not enforced
RowsPerFetch 10000 Number of records to request from the server at a time
RowsPerInsertion 10000 Number of records to send to the server in a batch
TruncateStrings 0

Whether to truncate strings when processing an INSERT

  • 0 = Do not truncate strings -- if a string is too long, it will not be inserted
  • 1 = Truncate strings when needed so they will fit in a restricted target string column
UpdateOnExistingPk 0

Whether to updated existing rows with the same primary key with the new data when executing an INSERT (JDBC only)

  • 0 = By default, new rows will be rejected when they have the same primary key as existing rows in a table; can be overridden with KI_HINT_UPDATE_ON_EXISTING_PK on individual statements
  • 1 = Inserted data will overwrite existing data with the same primary key
UseKeyLookup 0

Whether to process supported SELECT statements using high-performance distributed key lookup; using this may cause some additional overhead to determine if the table will support key lookups (JDBC only)

  • 0 = By default, use standard processing for all SELECT statements; this can be overridden with KI_HINT_KEY_LOOKUP on individual statements
  • 1 = Use high-performance distributed key lookup for supported SELECT statements, when possible

SSL Parameters

The following optional parameters should be used when connecting over SSL.

Config Parameter Default Value Description
SslAllowHostMismatch 0

Whether or not certificates whose host name does not match the Kinetica server are accepted by the client

  • 0 = Do not accept certificates whose host name is different than the Kinetica server host name
  • 1 = Accept certificates whose host name is different than the Kinetica server host name
SslCACertPassword   Password to the certificate store specified by either SslCACertPath or TrustedStorePath (JDBC only)
SslCACertPath   Path to client's trust store, used to validate the certificate from the Kinetica server
TrustedStorePath   Path to client's trust store, used to validate the certificate from the Kinetica server (JDBC-only override for SslCACertPath parameter)

Logging

Kinetica logs inbound SQL requests, internal calls made on behalf of those requests, and other debugging information. These logs can be found in the following log files:

  • /opt/gpudb/core/logs/host-manager-<hostname>-<datetime>.log: Contains all endpoint calls, including the initial call to /execute/sql and any endpoint calls made as a result of servicing the request
  • /opt/gpudb/sql/logs/sql-engine-<kinetica-hostname>.log: Contains detailed error messages