Search in sources :

Example 1 with H2Connection

use of org.apache.ignite.internal.processors.query.h2.H2Connection in project sharding-jdbc by shardingjdbc.

the class DBUnitUtil method getConnection.

/**
 * Get connection.
 * @param dbEnv Database environment
 * @param connection connection
 * @return database connection
 * @throws DatabaseUnitException DatabaseUnitException
 */
public static IDatabaseConnection getConnection(final DatabaseEnvironment dbEnv, final Connection connection) throws DatabaseUnitException {
    switch(dbEnv.getDatabaseType()) {
        case H2:
            return new H2Connection(connection, "PUBLIC");
        case MySQL:
            return new MySqlConnection(connection, null);
        case PostgreSQL:
            DatabaseConnection databaseConnection = new DatabaseConnection(connection);
            databaseConnection.getConfig().setProperty("http://www.dbunit.org/properties/datatypeFactory", new PostgresqlDataTypeFactory());
            return databaseConnection;
        case Oracle:
            return new OracleConnection(connection, "JDBC");
        case SQLServer:
            return new MsSqlConnection(connection);
        default:
            throw new UnsupportedOperationException(dbEnv.getDatabaseType().name());
    }
}
Also used : PostgresqlDataTypeFactory(org.dbunit.ext.postgresql.PostgresqlDataTypeFactory) MsSqlConnection(org.dbunit.ext.mssql.MsSqlConnection) MySqlConnection(org.dbunit.ext.mysql.MySqlConnection) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DatabaseConnection(org.dbunit.database.DatabaseConnection) OracleConnection(org.dbunit.ext.oracle.OracleConnection) H2Connection(org.dbunit.ext.h2.H2Connection)

Example 2 with H2Connection

use of org.apache.ignite.internal.processors.query.h2.H2Connection in project ignite by apache.

the class JdbcThinTransactionsLeaksMvccTest method usedConnectionCount.

/**
 * @param igx Node.
 * @return Count of detached connections.
 */
private int usedConnectionCount(IgniteEx igx) {
    ConnectionManager connMgr = ((IgniteH2Indexing) igx.context().query().getIndexing()).connections();
    Set<H2Connection> usedConns = GridTestUtils.getFieldValue(connMgr, "usedConns");
    return usedConns.size();
}
Also used : ConnectionManager(org.apache.ignite.internal.processors.query.h2.ConnectionManager) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) H2Connection(org.apache.ignite.internal.processors.query.h2.H2Connection)

Example 3 with H2Connection

use of org.apache.ignite.internal.processors.query.h2.H2Connection in project ignite by apache.

the class IgniteCacheQueryH2IndexingLeakTest method getStatementCacheSize.

/**
 * @param qryProcessor Query processor.
 * @return size of statement cache.
 */
private static int getStatementCacheSize(GridQueryProcessor qryProcessor) {
    IgniteH2Indexing h2Idx = (IgniteH2Indexing) qryProcessor.getIndexing();
    ConcurrentStripedPool<H2Connection> conns = GridTestUtils.getFieldValue(h2Idx.connections(), "connPool");
    return conns.stream().mapToInt(H2Connection::statementCacheSize).sum();
}
Also used : IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) H2Connection(org.apache.ignite.internal.processors.query.h2.H2Connection)

Aggregations

H2Connection (org.apache.ignite.internal.processors.query.h2.H2Connection)2 IgniteH2Indexing (org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)2 ConnectionManager (org.apache.ignite.internal.processors.query.h2.ConnectionManager)1 DatabaseConnection (org.dbunit.database.DatabaseConnection)1 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)1 H2Connection (org.dbunit.ext.h2.H2Connection)1 MsSqlConnection (org.dbunit.ext.mssql.MsSqlConnection)1 MySqlConnection (org.dbunit.ext.mysql.MySqlConnection)1 OracleConnection (org.dbunit.ext.oracle.OracleConnection)1 PostgresqlDataTypeFactory (org.dbunit.ext.postgresql.PostgresqlDataTypeFactory)1