use of org.apache.ignite.IgniteJdbcThinDriver in project ignite by apache.
the class LongDestroyDurableBackgroundTaskTest method batchQuery.
/**
* Batch query.
*
* @param ignite Ignite instance.
* @param qry SQL query.
* @param batchArgs Batch arguments.
* @throws Exception If failed.
*/
private void batchQuery(Ignite ignite, String qry, List<Object[]> batchArgs) throws Exception {
String host = ignite.configuration().getLocalHost();
int port = ignite.configuration().getClientConnectorConfiguration().getPort();
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(host + ":" + port))) {
try (Connection conn = new IgniteJdbcThinDriver().connect("jdbc:ignite:thin://" + host, new Properties())) {
PreparedStatement statement = conn.prepareStatement(qry);
for (Object[] args : batchArgs) {
for (int i = 1; i <= args.length; i++) statement.setObject(i, args[i - 1]);
statement.addBatch();
statement.clearParameters();
}
statement.executeBatch();
}
}
}
Aggregations