JDBC
HeavyDB supports JDBC connections.
Resources
You can connect securely to a JDBC session by defining the database URL (a colon-separated connection string with optional query string) and the keys/values in DriverManager.getConnection
properties.
You can define key values separated by colons in the main part of the connection string , or as key/value pairs separated by an ampersand (&) in an optional query string following the ? character.
jdbc:omnisci:<host_name>
must be defined in the main part of the connection string.
Valid keys in the connection URL are the same as those in the properties object. If defined in the main part of the connection string, they must appear in the following order:
host_name
- Name of the host. Must be defined in the main part of the connection string.port_num
- Port numberdb_name
- Name of the database.protocol:
<binary
|binary_tls
|http
|https
|https_insecure
>To connect using a secure connection through binary mode, the HEAVY.AI server must be running with an encrypted main port open.
Use binary TLS mode to explicitly connect using SSL with the default Java trust stores.
To connect using HTTPS, the HEAVY.AI web server must be running with HTTPS enabled.
To create an encrypted connection with no server validation, use
HTTPS_INSECURE
. Note: UsingHTTPS_INSECURE
is not recommended in a production environment.
For more information, see HEAVY.AI server configuration.
server_trust_store:
trust_store_path
- The path to a Java trust store holding the HEAVY.AI server public certificate.server_trust_store_pwd:
password
- The password to the trust store.pkiauth: true | false
- Enable PKI authentication. Iftrue
:The client X509 public certificate is supplied to the server for verification. Use the
sslcert
parameter to supply a file containing the certificate.The
user
parameter and thepassword
parameters are ignored and should be blank.
sslcert
certificate-path
- Path to the certificate and private key file, in PKCS12 format.sslkey
key-path
- Path to the SSL key.sslkey_password password
- Password for the SSL key defined insslkey
key-path
.max_rows
max_rows
- The maximum number of rows to return.
Examples
You can use the following connection URLs to connect to an HEAVY.AI database called test_DB
using port 6274
with max_rows
set to 10000.
If duplicate information is supplied in different sources of connection information, sources have priority as follows:
The main part of the URL.
The query portion of the URL.
The Properties object.
In the following connection URL, the database test_DB
would be used, and if logging is turned on, the driver would issue a warning:
The fields in the "main" colon-separated portion of the URL are interpreted strictly in the order defined in the list of keys: host_name
followed by port_num
, followed by db_name
, and so on. All of these fields can be specified in this portion of the connection string; however to specify a max_rows
field this way, all the preceding values must also be specified. Empty fields are not allowed. In this case, consider using a Properties object or a the query string portion of the URL.
You can also provide all options and parameters for a JDBC connection in a Java properties file; for example:
Supported JDBC Methods
Unsupported Features
Transaction statements
Cursors
Multiple result sets
Domains
Rules
Database procedures
Indexes
Keys
Constraints
Example
This example uses the JDBC interface to create a flight information database, then reads carrier information from the database.
Sequence
The key steps are:
Set connection parameters and credentials:
Register the JDBC driver:
Open a connection:
Create a table, add data, and query the database:
Extract data from the result set:
Compile and Run
Dependency components are also required in the classpath.
Source Code
Last updated