use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class ExtendedModeIT method test2_ExtendedModeDelete.
@Test
public void test2_ExtendedModeDelete() throws SQLException {
((CloudSpannerConnection) getConnection()).setAllowExtendedMode(true);
try (ResultSet rs = getConnection().createStatement().executeQuery("select count(*) from test where id<10")) {
while (rs.next()) {
assertEquals(10L, rs.getLong(1));
}
}
PreparedStatement ps = getConnection().prepareStatement("delete from test where id<?");
ps.setLong(1, 10L);
ps.executeUpdate();
getConnection().commit();
try (ResultSet rs = getConnection().createStatement().executeQuery("select count(*) from test where id<10")) {
while (rs.next()) {
assertEquals(0L, rs.getLong(1));
}
}
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class LoggerIT method testLogLongTransaction.
private void testLogLongTransaction(int logLevel) throws SQLException, InterruptedException {
StringWriter writer = new StringWriter();
DriverManager.setLogWriter(new PrintWriter(writer));
CloudSpannerDriver.setLongTransactionTrigger(1000L);
CloudSpannerConnection connection = (CloudSpannerConnection) getConnection();
connection.setAutoCommit(false);
connection.getLogger().setLogLevel(logLevel);
try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) {
while (rs.next()) {
}
}
// Wait for 7 seconds to ensure the keep-alive query is triggered
Thread.sleep(7000L);
connection.commit();
assertTrue(writer.toString().contains("Transaction has been inactive for more than 5 seconds and will do a keep-alive query"));
assertEquals(logLevel >= CloudSpannerDriver.DEBUG, writer.toString().contains("Transaction was started by: "));
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerStatementTest method testBatchDMLThenDDL.
@Test
public void testBatchDMLThenDDL() throws SQLException {
CloudSpannerConnection connection = createConnection();
CloudSpannerStatement statement = connection.createStatement();
thrown.expect(SQLFeatureNotSupportedException.class);
thrown.expectMessage("DDL statements may not be batched together with DML statements");
statement.addBatch(BATCH_DML);
statement.addBatch(BATCH_DDL);
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerStatementTest method testShowDdlOperations.
@Test
public void testShowDdlOperations() throws SQLException {
CloudSpannerConnection connection = createConnection();
CloudSpannerStatement statement = connection.createStatement();
Assert.assertTrue(statement.execute("SHOW_DDL_OPERATIONS"));
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerStatementTest method testBatchSelect.
@Test
public void testBatchSelect() throws SQLException {
CloudSpannerConnection connection = createConnection();
CloudSpannerStatement statement = connection.createStatement();
thrown.expect(SQLFeatureNotSupportedException.class);
thrown.expectMessage("SELECT statements may not be batched");
statement.addBatch("SELECT * FROM FOO");
}
Aggregations