JDBC
HeavyDB supports JDBC connections.
Resources
Resource | Description |
JAR file |
|
Code samples |
|
JDBC driver | ai.heavy.jdbc.HeavyAIDriver |
URL |
|
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
Method | Description |
Connection class | |
| Clear all warnings reported for this connection object. After calling |
| Disconnect the JDBC client session and frees associated resources. |
| Get a new, empty Statement object. |
| Get the Connection object current catalog name. |
| Get a |
| Get the first warning reported by calls on this Connection object. |
| Get the closed status of this Connection object:
|
| Get the connection status:
|
| Create a PreparedStatement object. HeavyDB makes no distinction between prepared and directly executed statements and queries. |
Driver | |
| Get the driver determination of whether or not it can open a connection to the URL. |
| Make a database connection to the specified URL. |
| Get the driver major version number. |
| Get the driver minor version number. |
| Get the parent Logger of all Loggers used by this driver. |
| Get driver property information. |
| Test if this driver is a JDBC-compliant driver. |
Statement | |
| Execute a SELECT query. |
| Execute an INSERT or DROP statement. |
| Get the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object. |
| Get the maximum number of rows that a ResultSet object produced by this Statement object can contain. |
| Get a new DatabaseMetaData object. |
| Set the limit for the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object. |
| Set the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number. Default is 100,000 rows.
If you do not specify a |
PreparedStatement | |
| Add an INSERT statement to a batch. |
| Execute a prepared query. HeavyDB makes no distinction between prepared and direct query execution. |
| Execute a batch of queries. |
| Create a prepared statement object for batch updates. |
| Set a dynamic parameter for batch statements. Dynamic parameters are supported with batch inserts only. |
| Set the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number. Default is 100,000 rows.
If you do not specify a |
ResultSet | |
| Releases this ResultSet's database and JDBC resources immediately. |
| Get a BigDecimal object. |
| Get a boolean object. |
| Get a java.sql.Date object. |
| Get a double object. |
| Get a float object. |
| Get an integer object. |
| Get a long integer object |
| Get a generic Object class representing the column value. |
| Get a short integer. |
| Get a String object. |
| Get a java.sql.Time object. |
| Get a java.sql.Timestamp object. |
ResultSetMetaData | |
| Get the designated column's table's catalog name. |
| Get the designated column's normal maximum width in characters. |
| Get the designated column's suggested title for use in printouts and displays. |
| Get the designated column's name. |
| Get the designated column's SQL type. |
| Get the designated column's database-specific type name. |
| Get the designated column's specified column size. |
| Get the designated column's number of digits to right of the decimal point. |
| Get the designated column's table's schema. |
| Get the designated column's table name. |
| Get whether the designated column is automatically numbered. |
| Get whether a column's case matters. |
| Get whether the designated column is a cash value. |
| Get whether a write on the designated column will definitely succeed. |
| Get the nullability of values in the designated column. |
| Get whether the designated column is definitely not writable. |
| Get whether the designated column can be used in a where clause. |
| Get whether values in the designated column are signed numbers. |
| Get whether it is possible to write to the designated column. |
DatabaseMetaData | |
| Get whether the current user can use all the tables returned by the method getTables in a SELECT statement. |
| Get whether a SQLException while autoCommit is true inidcates that all open ResultSets are closed, even ones that are holdable. |
| Get whether a data definition statement within a transaction forces the transaction to commit. |
| Get whether this database ignores a data definition statement within a transaction. |
| Get whether the return value for the method getMaxRowSize includes the SQL data types LONGVARCHAR and LONGVARBINARY. |
| Get whether a generated key will always be returned if the column name(s) or index(es) specified for the auto generated key column(s) are valid and the statement succeeds. |
| Get a description of a table's optimal set of columns that uniquely identifies a row. |
| Get the catalog names available in this database. |
| Get the String that this database uses as the separator between a catalog and table name. |
| Get the database vendor's preferred term for "catalog". |
| Get a description of table columns available in the specified catalog. |
| Get the connection that produced this metadata object. |
| Get the major version number of the underlying database. |
| Get the minor version number of the underlying database. |
| Get the name of this database product. |
| Get the version number of this database product. |
| Get this database's default transaction isolation level. |
| Get this JDBC driver's major version number. |
| Get this JDBC driver's minor version number. |
| Get the name of this JDBC driver. |
| Get the version number of this JDBC driver as a String. |
| Get all the "extra" characters that can be used in unquoted identifier names (those beyond a-z, A-Z, 0-9 and _). |
| Get the string used to quote SQL identifiers. |
| Get the major JDBC version number for this driver. |
| Get the minor JDBC version number for this driver. |
| Get the maximum number of hex characters this database allows in an inline binary literal. |
| Get the maximum number of characters that this database allows in a catalog name. |
| Get the maximum number of characters this database allows for a character literal. |
| Get the maximum number of characters this database allows for a column name. |
| Get the maximum number of columns this database allows in a GROUP BY clause. |
| Get the maximum number of columns this database allows in an index. |
| Get the maximum number of columns this database allows in an ORDER BY clause. |
| Get the maximum number of columns this database allows in a SELECT list. |
| Get the maximum number of columns this database allows in a table. |
| Get the maximum number of concurrent connections to this database that are possible. |
| Get the maximum number of characters that this database allows in a cursor name. |
| Get the maximum number of bytes this database allows for an index, including all of the parts of the index. |
| Get the maximum number of characters that this database allows in a procedure name. |
| Get the maximum number of bytes this database allows in a single row. |
| Get the maximum number of characters that this database allows in a schema name. |
| Get the maximum number of characters this database allows in an SQL statement. |
| Get the maximum number of active statements to this database that can be open at the same time. |
| Get the maximum number of characters this database allows in a table name. |
| Get the maximum number of tables this database allows in a SELECT statement. |
| Get the maximum number of characters this database allows in a user name. |
| Get a comma-separated list of math functions available with this database. |
| Get the schema names available in this database. |
| Get the database vendor's preferred term for "schema". |
| Get the string that can be used to escape wildcard characters. |
| Get a comma-separated list of all of this database's SQL keywords that are NOT also SQL:2003 keywords. |
| Indicates whether the SQLSTATE returned by SQLException.getSQLState is X/Open (now known as Open Group) SQL CLI or SQL:2003. |
| Get a description of the access rights for each table available in a catalog. |
| Get a description of the tables available in the given catalog. |
| Get the table types available in this database. |
| Get a comma-separated list of the time and date functions available with this database. |
| Get a description of all the data types supported by this database. |
| Get the URL for this DBMS. |
| Get the user name as known to this database. |
| Get whether a catalog appears at the start of a fully qualified table name. |
| Get whether this database supports concatenations between NULL and non-NULL values being NULL. |
| Get whether NULL values are sorted at the end regardless of sort order. |
| Get whether NULL values are sorted at the start regardless of sort order. |
| Get whether NULL values are sorted high. |
| Get whether NULL values are sorted low. |
| Get whether deletes made by others are visible. |
| Get whether inserts made by others are visible. |
| Get whether updates made by others are visible. |
| Get whether a result set's own deletes are visible. |
| Get whether a result set's own inserts are visible. |
| Get whether for the given type of ResultSet object, the result set's own updates are visible. |
| Get whether this database treats mixed case unquoted SQL identifiers as case insensitive and stores them in lower case. |
| Get whether this database treats mixed case quoted SQL identifiers as case insensitive and stores them in lower case. |
| Get whether this database treats mixed case unquoted SQL identifiers as case insensitive and stores them in mixed case. |
| Get whether this database treats mixed case quoted SQL identifiers as case insensitive and stores them in mixed case. |
| Get whether this database treats mixed case unquoted SQL identifiers as case insensitive and stores them in upper case. |
| Get whether this database treats mixed case quoted SQL identifiers as case insensitive and stores them in upper case. |
| Get whether this database supports ALTER TABLE with add column. |
| Get whether this database supports ALTER TABLE with drop column. |
| Get whether this database supports the ANSI92 entry level SQL grammar. |
| Get whether this database supports the ANSI92 full SQL grammar supported. |
| Get whether this database supports the ANSI92 intermediate SQL grammar supported. |
| Get whether this database supports batch updates. |
| Get whether a catalog name can be used in a data manipulation statement. |
| Get whether a catalog name can be used in an index definition statement. |
| Get whether a catalog name can be used in a privilege definition statement. |
| Get whether a catalog name can be used in a procedure call statement. |
| Get whether a catalog name can be used in a table definition statement. |
| Get whether this database supports column aliasing. |
| Get whether this database supports the JDBC scalar function CONVERT for the conversion of one JDBC type to another. |
| Get whether this database supports the JDBC scalar function CONVERT for conversions between the JDBC types fromType and toType. |
| Get whether this database supports the ODBC Core SQL grammar. |
| Get whether this database supports correlated subqueries. |
| Get whether this database supports both data definition and data manipulation statements within a transaction. |
| Get whether this database supports only data manipulation statements within a transaction. |
| Get whether, when table correlation names are supported, they are restricted to being different from the names of the tables. |
| Get whether this database supports expressions in ORDER BY lists. |
| Get whether this database supports the ODBC Extended SQL grammar. |
| Get whether this database supports full nested outer joins. |
| Get whether this database supports some form of GROUP BY clause. |
| Get whether this database supports using columns not included in the SELECT statement in a GROUP BY clause provided that all of the columns in the SELECT statement are included in the GROUP BY c |
| Get whether this database supports using a column that is not in the SELECT statement in a GROUP BY clause. |
| Get whether this database supports the SQL Integrity Enhancement Facility. |
| Get whether this database supports specifying a LIKE escape clause. |
| Get whether this database provides limited support for outer joins. |
| Get whether this database supports the ODBC Minimum SQL grammar. |
| Get whether this database treats mixed case unquoted SQL identifiers as case sensitive and as a result stores them in mixed case. |
| Get whether this database treats mixed case quoted SQL identifiers as case sensitive and as a result stores them in mixed case. |
| Get whether it is possible to have multiple ResultSet objects returned from a CallableStatement object simultaneously. |
| Get whether this database supports getting multiple ResultSet objects from a single call to the method execute. |
| Get whether this database allows having multiple transactions open at once (on different connections). |
| Get whether this database supports named parameters to callable statements. |
| Get whether columns in this database may be defined as non-nullable. |
| Get whether this database supports keeping cursors open across commits. |
| Get whether this database supports keeping cursors open across rollbacks. |
| Get whether this database supports keeping statements open across commits. |
| Get whether this database supports keeping statements open across rollbacks. |
| Get whether this database supports using a column that is not in the SELECT statement in an ORDER BY clause. |
| Get whether this database supports some form of outer join. |
| Get whether this database supports positioned DELETE statements. |
| Get whether this database supports positioned UPDATE statements. |
| Get whether this database supports the given concurrency type in combination with the given result set type. |
| Get whether this database supports the given result set holdability. |
| Get whether this database supports the given result set type. |
| Get whether this database supports savepoints. |
| Get whether a schema name can be used in a data manipulation statement. |
| Get whether a schema name can be used in an index definition statement. |
| Get whether a schema name can be used in a privilege definition statement. |
| Get whether a schema name can be used in a table definition statement. |
| Get whether this database supports SELECT FOR UPDATE statements. |
| Get whether this database supports statement pooling. |
| Get whether this database supports invoking user-defined or vendor functions using the stored procedure escape syntax |
| Get whether this database supports stored procedure calls that use the stored procedure escape syntax. |
| Get whether this database supports subqueries in comparison expressions. |
| Get whether this database supports subqueries in EXISTS expressions. |
| Get whether this database supports subqueries in IN expressions. |
| Get whether this database supports subqueries in quantified expressions. |
| Get whether this database supports table correlation names. |
| Get whether this database supports the given transaction isolation level. |
| Get whether this database supports transactions. |
| Get whether this database supports SQL UNION. |
| Get whether this database supports SQL UNION ALL. |
| Get whether this database uses a file for each table. |
| Get whether this database stores tables in a local file. |
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