use of org.apache.ignite.internal.processors.query.GridQueryIndexing in project ignite by apache.
the class JdbcConnection method prepareStatement.
/** {@inheritDoc} */
@Override
public PreparedStatement prepareStatement(String sql, int resSetType, int resSetConcurrency, int resSetHoldability) throws SQLException {
ensureNotClosed();
if (resSetType != TYPE_FORWARD_ONLY)
throw new SQLFeatureNotSupportedException("Invalid result set type (only forward is supported.)");
if (resSetConcurrency != CONCUR_READ_ONLY)
throw new SQLFeatureNotSupportedException("Invalid concurrency (updates are not supported).");
if (!txAllowed && resSetHoldability != HOLD_CURSORS_OVER_COMMIT)
throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
JdbcPreparedStatement stmt;
if (!stream)
stmt = new JdbcPreparedStatement(this, sql);
else {
GridQueryIndexing idx = ignite().context().query().getIndexing();
PreparedStatement nativeStmt = prepareNativeStatement(sql);
if (!idx.isInsertStatement(nativeStmt))
throw new IgniteSQLException("Only INSERT operations are supported in streaming mode", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
IgniteDataStreamer streamer = ignite().dataStreamer(cacheName);
streamer.autoFlushFrequency(streamFlushTimeout);
streamer.allowOverwrite(streamAllowOverwrite);
if (streamNodeBufSize > 0)
streamer.perNodeBufferSize(streamNodeBufSize);
if (streamNodeParOps > 0)
streamer.perNodeParallelOperations(streamNodeParOps);
stmt = new JdbcStreamedPreparedStatement(this, sql, streamer, nativeStmt);
}
statements.add(stmt);
return stmt;
}
Aggregations