Search in sources :

Example 6 with ShardingConnection

use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.

the class StatementAdapterTest method init.

@Before
public void init() {
    ShardingConnection shardingConnection = getShardingDataSource().getConnection();
    shardingConnections.add(shardingConnection);
    statements.put(getCurrentDatabaseType(), shardingConnection.createStatement());
}
Also used : ShardingConnection(io.shardingjdbc.core.jdbc.core.connection.ShardingConnection) Before(org.junit.Before)

Example 7 with ShardingConnection

use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.

the class UnsupportedOperationPreparedStatementTest method init.

@Before
public void init() {
    ShardingConnection shardingConnection = getShardingDataSource().getConnection();
    shardingConnections.add(shardingConnection);
    PreparedStatement preparedStatement = shardingConnection.prepareStatement(DatabaseTestSQL.SELECT_WITH_ALIAS_SQL);
    statements.add(preparedStatement);
}
Also used : ShardingConnection(io.shardingjdbc.core.jdbc.core.connection.ShardingConnection) PreparedStatement(java.sql.PreparedStatement) Before(org.junit.Before)

Example 8 with ShardingConnection

use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.

the class UnsupportedOperationResultSetTest method init.

@Before
public void init() throws SQLException {
    ShardingConnection connection = getShardingDataSource().getConnection();
    shardingConnections.add(connection);
    Statement statement = connection.createStatement();
    statements.add(statement);
    resultSets.add(statement.executeQuery(sql));
}
Also used : Statement(java.sql.Statement) ShardingConnection(io.shardingjdbc.core.jdbc.core.connection.ShardingConnection) Before(org.junit.Before)

Example 9 with ShardingConnection

use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.

the class ConnectionAdapterTest method assertSetTransactionIsolation.

@Test
public void assertSetTransactionIsolation() throws SQLException {
    try (ShardingConnection actual = getShardingDataSource().getConnection()) {
        assertThat(actual.getTransactionIsolation(), is(Connection.TRANSACTION_READ_UNCOMMITTED));
        actual.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
        actual.createStatement().executeQuery(sql);
        assertTransactionIsolation(actual, Connection.TRANSACTION_SERIALIZABLE);
        if (DatabaseType.Oracle != getCurrentDatabaseType()) {
            actual.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
            assertTransactionIsolation(actual, Connection.TRANSACTION_READ_COMMITTED);
        }
    }
}
Also used : ShardingConnection(io.shardingjdbc.core.jdbc.core.connection.ShardingConnection) Test(org.junit.Test) AbstractShardingJDBCDatabaseAndTableTest(io.shardingjdbc.core.common.base.AbstractShardingJDBCDatabaseAndTableTest)

Example 10 with ShardingConnection

use of io.shardingjdbc.core.jdbc.core.connection.ShardingConnection in project sharding-jdbc by shardingjdbc.

the class ConnectionAdapterTest method assertSetHoldability.

@Test
public void assertSetHoldability() throws SQLException {
    try (ShardingConnection actual = getShardingDataSource().getConnection()) {
        actual.setHoldability(ResultSet.CONCUR_READ_ONLY);
        assertThat(actual.getHoldability(), is(ResultSet.CLOSE_CURSORS_AT_COMMIT));
    }
}
Also used : ShardingConnection(io.shardingjdbc.core.jdbc.core.connection.ShardingConnection) Test(org.junit.Test) AbstractShardingJDBCDatabaseAndTableTest(io.shardingjdbc.core.common.base.AbstractShardingJDBCDatabaseAndTableTest)

Aggregations

ShardingConnection (io.shardingjdbc.core.jdbc.core.connection.ShardingConnection)19 Before (org.junit.Before)8 AbstractShardingJDBCDatabaseAndTableTest (io.shardingjdbc.core.common.base.AbstractShardingJDBCDatabaseAndTableTest)7 Test (org.junit.Test)7 Connection (java.sql.Connection)4 Statement (java.sql.Statement)4 ResultSet (java.sql.ResultSet)2 PreparedStatement (java.sql.PreparedStatement)1