OdbcConnection
classin packageklyn.databases.sql.odbc
public class OdbcConnection implements Connection
OdbcConnection
All Implemented Interfaces: Connection

ODBC SQL connection.

The connection can be opened directly with an ODBC connection string or via a DSN shortcut. The ODBC driver manager and the target ODBC driver must be installed on the host system.

import klyn.databases.sql
import klyn.databases.sql.odbc

cnx = OdbcConnection.open("odbc:DSN=app;UID=app;PWD=secret")
rows = cnx.statement().executeQuery("select current_date")
cnx.close()
import klyn.databases.sql

cnx = DriverManager.connect("odbc://app", {"user": "app", "password": "secret"})
prepared = cnx.prepared("select * from users where id = ?")
prepared.setInt(1, 42)
rows = prepared.query()
Properties
Modifier and Type Member Description
public property autoCommit
autoCommit as Boolean
True when each statement is committed immediately.
public property catalog
catalog as String
Current catalog when supported by the ODBC driver.
public readonly property clientInfo
clientInfo as SortedMap<String, String>
Mutable client-info map.
public readonly property closed
closed as Boolean
True after close() has been called.
public readonly property connected
connected as Boolean
True when the ODBC handle is still usable.
public property holdability
holdability as ResultSetHoldability
Current result-set holdability.
public readonly property metadata
metadata as DatabaseMetaData
Database metadata facade.
public property networkTimeoutMillis
networkTimeoutMillis as Int
Connection timeout in milliseconds.
public property readOnly
readOnly as Boolean
True when the connection is read-only.
public property schema
schema as String
Current schema tracked by the Klyn connection.
public readonly property sslContext
sslContext as SSLContext
ODBC does not use the Klyn SSL context directly.
public property transactionIsolation
transactionIsolation as TransactionIsolation
Current transaction isolation level tracked by Klyn.
public readonly property url
url as String
Effective connection URL.
public readonly property userName
userName as String
Effective user name.
public readonly property warning
warning as SQLWarning
Warning chain.
Methods
Modifier and Type Member Description
public callable
callable(sql as String, resultSetType as ResultSetType = ResultSetType.FORWARD_ONLY, concurrency as ResultSetConcurrency = ResultSetConcurrency.READ_ONLY, holdability as ResultSetHoldability = ResultSetHoldability.CLOSE_CURSORS_AT_COMMIT) as CallableStatement throws SQLException
Prepares a stored-procedure call.
public clearWarnings
clearWarnings() as Void
Clears the warning chain.
public override close
close() as Void
Closes the ODBC connection.
public commit
commit() as Void throws SQLException
Commits the current transaction.
public static connect
connect(url as String, user as String = "", password as String = "") as OdbcConnection throws SQLException
Opens an ODBC connection from URL and credentials.
public createStatement
createStatement(resultSetType as ResultSetType = ResultSetType.FORWARD_ONLY, concurrency as ResultSetConcurrency = ResultSetConcurrency.READ_ONLY, holdability as ResultSetHoldability = ResultSetHoldability.CLOSE_CURSORS_AT_COMMIT) as Statement throws SQLException
Compatibility alias of statement(...).
public isValid
isValid(timeoutSeconds as Int = 0) as Boolean
Returns true when the ODBC connection is still valid.
public nativeSql
nativeSql(sql as String) as String
Returns SQL text unchanged; dialect conversion belongs to the target ODBC driver.
public static open
open(url as String, properties as Map<String, String> = null) as OdbcConnection throws SQLException
Opens an ODBC connection from a Klyn URL and optional connection properties.
public prepareCall
prepareCall(sql as String, resultSetType as ResultSetType = ResultSetType.FORWARD_ONLY, concurrency as ResultSetConcurrency = ResultSetConcurrency.READ_ONLY, holdability as ResultSetHoldability = ResultSetHoldability.CLOSE_CURSORS_AT_COMMIT) as CallableStatement throws SQLException
Compatibility alias of callable(...).
public prepareStatement
prepareStatement(sql as String, resultSetType as ResultSetType = ResultSetType.FORWARD_ONLY, concurrency as ResultSetConcurrency = ResultSetConcurrency.READ_ONLY, holdability as ResultSetHoldability = ResultSetHoldability.CLOSE_CURSORS_AT_COMMIT) as PreparedStatement throws SQLException
Compatibility alias of prepared(...).
public prepared
prepared(sql as String, resultSetType as ResultSetType = ResultSetType.FORWARD_ONLY, concurrency as ResultSetConcurrency = ResultSetConcurrency.READ_ONLY, holdability as ResultSetHoldability = ResultSetHoldability.CLOSE_CURSORS_AT_COMMIT) as PreparedStatement throws SQLException
Prepares a SQL statement through ODBC.
public releaseSavepoint
releaseSavepoint(savepoint as Savepoint) as Void throws SQLException
Releases a savepoint using SQL RELEASE SAVEPOINT.
public rollback
rollback(savepoint as Savepoint = null) as Void throws SQLException
Rolls back the current transaction or one savepoint.
public savepoint
savepoint(name as String = "") as Savepoint throws SQLException
Creates a database savepoint using SQL SAVEPOINT.
public statement
statement(resultSetType as ResultSetType = ResultSetType.FORWARD_ONLY, concurrency as ResultSetConcurrency = ResultSetConcurrency.READ_ONLY, holdability as ResultSetHoldability = ResultSetHoldability.CLOSE_CURSORS_AT_COMMIT) as Statement throws SQLException
Creates a plain ODBC statement.
Inherited Methods
methodInherited Methods from AutoClosable: close