Search in sources :

Example 1 with ShardingConnection

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

the class UnsupportedOperationStatementTest method init.

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

Example 2 with ShardingConnection

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

the class UnsupportedUpdateOperationResultSetTest method init.

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

Example 3 with ShardingConnection

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

the class ConnectionAdapterTest method assertClose.

@Test
public void assertClose() throws SQLException {
    try (ShardingConnection actual = getShardingDataSource().getConnection()) {
        actual.createStatement().executeQuery(sql);
        assertClose(actual, false);
        actual.close();
        assertClose(actual, true);
    }
}
Also used : ShardingConnection(io.shardingjdbc.core.jdbc.core.connection.ShardingConnection) Test(org.junit.Test) AbstractShardingJDBCDatabaseAndTableTest(io.shardingjdbc.core.common.base.AbstractShardingJDBCDatabaseAndTableTest)

Example 4 with ShardingConnection

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

the class ConnectionAdapterTest method assertClose.

private void assertClose(final ShardingConnection actual, final boolean closed) throws SQLException {
    assertThat(actual.isClosed(), is(closed));
    assertThat(actual.getCachedConnections().size(), is(2));
    for (Connection each : actual.getCachedConnections().values()) {
        assertThat(each.isClosed(), is(closed));
    }
}
Also used : Connection(java.sql.Connection) ShardingConnection(io.shardingjdbc.core.jdbc.core.connection.ShardingConnection)

Example 5 with ShardingConnection

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

the class ResultSetAdapterTest method init.

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

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