public class OdbcConnection implements 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()| Modifier and Type | Member | Description |
|---|---|---|
| public property | autoCommitautoCommit as Boolean: |
True when each statement is committed immediately. |
| public property | catalogcatalog as String: |
Current catalog when supported by the ODBC driver. |
| public readonly property | clientInfo | Mutable client-info map. |
| public readonly property | closedclosed as Boolean: |
True after `close()` has been called. |
| public readonly property | connectedconnected as Boolean: |
True when the ODBC handle is still usable. |
| public property | holdabilityholdability as ResultSetHoldability: |
Current result-set holdability. |
| public readonly property | metadatametadata as DatabaseMetaData: |
Database metadata facade. |
| public property | networkTimeoutMillisnetworkTimeoutMillis as Int: |
Connection timeout in milliseconds. |
| public property | readOnlyreadOnly as Boolean: |
True when the connection is read-only. |
| public property | schemaschema as String: |
Current schema tracked by the Klyn connection. |
| public readonly property | sslContextsslContext as SSLContext: |
ODBC does not use the Klyn SSL context directly. |
| public property | transactionIsolationtransactionIsolation as TransactionIsolation: |
Current transaction isolation level tracked by Klyn. |
| public readonly property | urlurl as String: |
Effective connection URL. |
| public readonly property | userNameuserName as String: |
Effective user name. |
| public readonly property | warningwarning as SQLWarning: |
Warning chain. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | callablecallable(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 | clearWarningsclearWarnings() as Void: |
Clears the warning chain. |
| public override | closeclose() as Void: |
Closes the ODBC connection. |
| public | commitcommit() as Void throws SQLException: |
Commits the current transaction. |
| public static | connectconnect(url as String, user as String = "", password as String = "") as OdbcConnection throws SQLException: |
Opens an ODBC connection from URL and credentials. |
| public | createStatementcreateStatement(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 | Returns true when the ODBC connection is still valid. |
| public | nativeSql | Returns SQL text unchanged; dialect conversion belongs to the target ODBC driver. |
| public static | openopen(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 | prepareCallprepareCall(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 | prepareStatementprepareStatement(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 | preparedprepared(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 | releaseSavepointreleaseSavepoint(savepoint as Savepoint) as Void throws SQLException: |
Releases a savepoint using SQL `RELEASE SAVEPOINT`. |
| public | rollbackrollback(savepoint as Savepoint = null) as Void throws SQLException: |
Rolls back the current transaction or one savepoint. |
| public | savepointsavepoint(name as String = "") as Savepoint throws SQLException: |
Creates a database savepoint using SQL `SAVEPOINT`. |
| public | statementstatement(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. |