oraffi library
Oracle FFI Library for Dart
A high-performance Oracle database client library for Dart using FFI to wrap the Oracle ODPI-C library.
Features
- Connection pooling
- Prepared statements
- Transaction management
- Multiple data type support
- Secure credential management
Usage
Basic Connection Example
import 'package:oraffi/oraffi.dart';
void main() async {
final oracleDb = OracleDb();
// Initialize Oracle client
await oracleDb.initOracleClient();
// Create configuration (from environment variables)
final config = OracleConfig.fromEnvironment();
// Create connection
final connection = await oracleDb.createConnection(config: config);
try {
// Execute query
final results = await connection.query(
'SELECT * FROM employees WHERE department_id = ?',
params: [10],
);
for (final row in results) {
print(row);
}
// Commit transaction
await connection.commit();
} finally {
await connection.close();
}
await oracleDb.shutdown();
}
Connection Pool Example
void main() async {
final oracleDb = OracleDb();
await oracleDb.initOracleClient();
final config = OracleConfig.create(
username: 'user',
password: 'password',
connectionString: 'host:1521/service',
);
// Create connection pool
await oracleDb.createPool(config: config);
// Get connection from pool
final conn = await oracleDb.getConnection();
try {
final results = await conn.query('SELECT * FROM table');
print(results);
} finally {
await conn.close(); // Returns to pool
}
await oracleDb.shutdown();
}
Classes
- ColumnInfo
- Column information
- LibraryLoader
- Library loader for Oracle ODPI-C native library
-
ManagedResource<
T> - Resource wrapper that ensures proper cleanup using try-finally pattern
- MemoryManager
- Memory manager for FFI pointer lifecycle management
- OracleConfig
- Configuration class for Oracle database connections
- OracleConnection
- OracleConnectionPool
- Connection pool for Oracle database connections
- OracleDb
- Main entry point for Oracle database operations
- OracleLob
- Represents a Large Object (LOB) in Oracle
- OracleResultSet
- Represents a result set from a query
- OracleStatement
- Represents a prepared SQL statement for executing queries and DML operations.
- OracleVariable
- Represents a bind variable for IN/OUT parameters
- PointerUtils
- Pointer utilities for common FFI operations
- PoolConfig
- Connection pool configuration
- PoolStatistics
- Pool statistics
- StringUtils
- String conversion utilities for FFI
Enums
- BindDirection
- Bind direction for variables
- LobType
- LOB types
- TransactionIsolation
- Represents a connection to an Oracle database.
Constants
- DPI_FAILURE → const int
- DPI_NATIVE_TYPE_BYTES → const int
- DPI_NATIVE_TYPE_DOUBLE → const int
- DPI_NATIVE_TYPE_FLOAT → const int
- DPI_NATIVE_TYPE_INT64 → const int
- DPI_NATIVE_TYPE_TIMESTAMP → const int
- DPI_NATIVE_TYPE_UINT64 → const int
- DPI_ORACLE_TYPE_BLOB → const int
- DPI_ORACLE_TYPE_CLOB → const int
- DPI_ORACLE_TYPE_DATE → const int
- DPI_ORACLE_TYPE_NUMBER → const int
- DPI_ORACLE_TYPE_TIMESTAMP → const int
- DPI_ORACLE_TYPE_VARCHAR → const int
- DPI_STMT_TYPE_DELETE → const int
- DPI_STMT_TYPE_INSERT → const int
- DPI_STMT_TYPE_SELECT → const int
- DPI_STMT_TYPE_UPDATE → const int
- DPI_SUCCESS → const int
Functions
-
withMemoryManager<
R> (R action(MemoryManager)) → R - Helper function to run code with automatic memory management
Exceptions / Errors
- OracleConfigurationException
- Exception thrown when configuration is invalid or missing
- OracleConnectionException
- Exception thrown when connection to Oracle database fails
- OracleContextException
- Exception thrown when context initialization fails
- OracleException
- Base exception class for all Oracle-related errors
- OracleMemoryException
- Exception thrown when memory allocation or management fails
- OraclePoolException
- Exception thrown when connection pool operations fail
- OracleResultSetException
- Exception thrown when result set operations fail
- OracleStatementException
- Exception thrown when SQL statement execution fails