use of org.apache.calcite.avatica.AvaticaPreparedStatement in project calcite-avatica by apache.
the class JdbcMeta method prepare.
public StatementHandle prepare(ConnectionHandle ch, String sql, long maxRowCount) {
try {
final Connection conn = getConnection(ch.id);
final PreparedStatement statement = conn.prepareStatement(sql);
final int id = getStatementIdGenerator().getAndIncrement();
Meta.StatementType statementType = null;
if (statement.isWrapperFor(AvaticaPreparedStatement.class)) {
final AvaticaPreparedStatement avaticaPreparedStatement;
avaticaPreparedStatement = statement.unwrap(AvaticaPreparedStatement.class);
statementType = avaticaPreparedStatement.getStatementType();
}
// Set the maximum number of rows
setMaxRows(statement, maxRowCount);
getStatementCache().put(id, new StatementInfo(statement));
StatementHandle h = new StatementHandle(ch.id, id, signature(statement.getMetaData(), statement.getParameterMetaData(), sql, statementType));
LOG.trace("prepared statement {}", h);
return h;
} catch (SQLException e) {
throw propagate(e);
}
}
Aggregations