OdbcService class

High-level service for ODBC database operations.

Provides a clean API for connecting to databases, executing queries, managing transactions, using prepared statements, connection pooling, and catalog queries. Includes input validation and automatic error handling.

Example:

final service = OdbcService(repository);
await service.initialize();
final connResult = await service.connect('DSN=MyDatabase');

Constructors

OdbcService(IOdbcRepository _repository)
Creates a new OdbcService instance.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

beginTransaction(String connectionId, IsolationLevel isolationLevel) Future<Result<int>>
Begins a new transaction with the specified isolation level.
bulkInsert(String connectionId, String table, List<String> columns, List<int> dataBuffer, int rowCount) Future<Result<int>>
Performs a bulk insert operation using the native ODBC bulk insert API.
catalogColumns(String connectionId, String table) Future<Result<QueryResult>>
Queries the database catalog for column information.
catalogTables(String connectionId, {String catalog = '', String schema = ''}) Future<Result<QueryResult>>
Queries the database catalog for table information.
catalogTypeInfo(String connectionId) Future<Result<QueryResult>>
Queries the database catalog for data type information.
closeStatement(String connectionId, int stmtId) Future<Result<Unit>>
Closes and releases a prepared statement.
commitTransaction(String connectionId, int txnId) Future<Result<Unit>>
Commits a transaction.
connect(String connectionString, {ConnectionOptions? options}) Future<Result<Connection>>
Establishes a new database connection.
createSavepoint(String connectionId, int txnId, String name) Future<Result<Unit>>
Creates a savepoint within an active transaction.
disconnect(String connectionId) Future<Result<Unit>>
Closes and disconnects a connection.
executePrepared(String connectionId, int stmtId, [List? params]) Future<Result<QueryResult>>
Executes a prepared statement with optional parameters.
executeQuery(String connectionId, String sql) Future<Result<QueryResult>>
Executes a SQL query and returns the result set.
executeQueryMulti(String connectionId, String sql) Future<Result<QueryResult>>
Executes a SQL query that returns multiple result sets.
executeQueryParams(String connectionId, String sql, List params) Future<Result<QueryResult>>
Executes a SQL query with parameters.
getMetrics() Future<Result<OdbcMetrics>>
Gets performance and operational metrics.
initialize() Future<Result<Unit>>
Initializes the ODBC environment.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
poolClose(int poolId) Future<Result<Unit>>
Closes the specified connection pool and releases all connections.
poolCreate(String connectionString, int maxSize) Future<Result<int>>
Creates a new connection pool.
poolGetConnection(int poolId) Future<Result<Connection>>
Gets a connection from the specified connection pool.
poolGetState(int poolId) Future<Result<PoolState>>
Gets the current state of the specified connection pool.
poolHealthCheck(int poolId) Future<Result<bool>>
Performs a health check on the specified connection pool.
poolReleaseConnection(String connectionId) Future<Result<Unit>>
Releases a connection back to its pool.
prepare(String connectionId, String sql, {int timeoutMs = 0}) Future<Result<int>>
Prepares a SQL statement for execution.
releaseSavepoint(String connectionId, int txnId, String name) Future<Result<Unit>>
Releases a savepoint. The transaction remains active.
rollbackToSavepoint(String connectionId, int txnId, String name) Future<Result<Unit>>
Rolls back to a savepoint. The transaction remains active.
rollbackTransaction(String connectionId, int txnId) Future<Result<Unit>>
Rolls back a transaction.
toString() String
A string representation of this object.
inherited
withRetry<T extends Object>(Future<Result<T>> operation(), {RetryOptions? options}) Future<Result<T>>
Runs operation with automatic retry on retryable OdbcErrors.

Operators

operator ==(Object other) bool
The equality operator.
inherited