use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerStatementTest method prepareUnsupportedStatementTest.
private CloudSpannerStatement prepareUnsupportedStatementTest() throws SQLException {
thrown.expect(SQLFeatureNotSupportedException.class);
CloudSpannerConnection connection = createConnection();
CloudSpannerStatement statement = connection.createStatement();
return statement;
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerTransactionTest method testInterfaceMethods.
/**
* Run some simple tests for methods that are needed for the interface, but
* do not do anything
*
* @throws SQLException
*/
@Test
public void testInterfaceMethods() throws SQLException {
CloudSpannerConnection connection = CloudSpannerTestObjects.createConnection();
try (CloudSpannerTransaction tx = new CloudSpannerTransaction(null, connection)) {
Assert.assertNull(tx.read(null, null, null));
Assert.assertNull(tx.readUsingIndex(null, null, null, null));
Assert.assertNull(tx.readRow(null, null, null));
Assert.assertNull(tx.readRowUsingIndex(null, null, null, null));
Assert.assertNull(tx.analyzeQuery(null, null));
}
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class DeleteWorker method createSelect.
private static Select createSelect(CloudSpannerConnection connection, Delete delete) throws SQLException {
TableKeyMetaData table = connection.getTable(CloudSpannerDriver.unquoteIdentifier(delete.getTable().getName()));
List<String> keyCols = table.getKeyColumns().stream().map(x -> CloudSpannerDriver.quoteIdentifier(delete.getTable().getName()) + "." + CloudSpannerDriver.quoteIdentifier(x)).collect(Collectors.toList());
StringBuilder sql = new StringBuilder();
sql.append("SELECT ").append(String.join(", ", keyCols));
sql.append("\nFROM ").append(CloudSpannerDriver.quoteIdentifier(delete.getTable().getName()));
sql.append("\nWHERE ").append(delete.getWhere().toString());
try {
return (Select) CCJSqlParserUtil.parse(sql.toString());
} catch (JSQLParserException e) {
throw new CloudSpannerSQLException("Could not parse generated SELECT statement: " + sql, Code.INVALID_ARGUMENT);
}
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerXAConnectionTest method createSubject.
private CloudSpannerXAConnection createSubject() throws SQLException {
CloudSpannerConnection conn = CloudSpannerTestObjects.createConnection();
CloudSpannerXAConnection res = new CloudSpannerXAConnection(conn);
return res;
}
use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerXADataSourceTest method testGetConnection.
@Test
public void testGetConnection() throws SQLException {
CloudSpannerXADataSource subject = new CloudSpannerXADataSource();
CloudSpannerDataSourceTest.setCommonDataSourceTestProperties(subject);
subject.setCreateXATable(false);
CloudSpannerXAConnection connection = subject.getXAConnection();
assertNotNull(connection);
assertNotNull(subject.getDescription());
Connection con = connection.getConnection();
Assert.assertTrue(con.isWrapperFor(CloudSpannerConnection.class));
CloudSpannerConnection cloudSpannerConnection = con.unwrap(CloudSpannerConnection.class);
CloudSpannerDataSourceTest.testCommonDataSourceTestProperties(cloudSpannerConnection);
}
Aggregations