@Override public void execute(final Statement statement) throws SQLException { statement.setFetchSize(rows); } });
@Override public void setFetchSize(int rows) throws SQLException { targetStatement.setFetchSize(rows); }
@Override public void setFetchSize(int rows) throws SQLException { statement.setFetchSize(rows); }
@Override public void setFetchSize(int rows) throws SQLException { delegate.setFetchSize(rows); }
public void setFetchSize(int rows) throws SQLException { stmt.setFetchSize(rows); }
private Statement createBatchStatement(Connection connection) throws SQLException, InterruptedException { Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); statement.setFetchSize(Integer.MIN_VALUE); return statement; }
class StreamingStatementCreator implements PreparedStatementCreator { private final String sql; public StreamingStatementCreator(String sql) { this.sql = sql; } @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); statement.setFetchSize(Integer.MIN_VALUE); return statement; } }
@Override public void setFetchSize(int rows) throws SQLException { checkOpen(); try { stmt.setFetchSize(rows); } catch (Throwable t) { throw checkException(t); } }
private Statement readTableStatement() throws SQLException { // TODO read option int rowsFetchSize = 2000; Statement statement = jdbcConnection.connection().createStatement(); // the default cursor is FORWARD_ONLY statement.setFetchSize(rowsFetchSize); return statement; }
@Override public void statement_setFetchSize(StatementProxy statement, int rows) throws SQLException { if (this.pos < filterSize) { nextFilter().statement_setFetchSize(this, statement, rows); return; } statement.getRawObject().setFetchSize(rows); }
private Statement readTableStatement(Connection conn) throws SQLException { int rowsFetchSize = taskContext.config().rowsFetchSize(); Statement statement = conn.createStatement(); // the default cursor is FORWARD_ONLY statement.setFetchSize(rowsFetchSize); return statement; }
/** * Prepare the given JDBC Statement (or PreparedStatement or CallableStatement), * applying statement settings such as fetch size, max rows, and query timeout. * @param stmt the JDBC Statement to prepare * @throws SQLException if thrown by JDBC API * @see #setFetchSize * @see #setMaxRows * @see #setQueryTimeout * @see org.springframework.jdbc.datasource.DataSourceUtils#applyTransactionTimeout */ protected void applyStatementSettings(Statement stmt) throws SQLException { int fetchSize = getFetchSize(); if (fetchSize != -1) { stmt.setFetchSize(fetchSize); } int maxRows = getMaxRows(); if (maxRows != -1) { stmt.setMaxRows(maxRows); } DataSourceUtils.applyTimeout(stmt, getDataSource(), getQueryTimeout()); }
@Override public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final RouteUnit routeUnit, final ConnectionMode connectionMode) throws SQLException { Statement statement = getJdbcExecutorWrapper().createStatement(connection, routeUnit.getSqlUnit(), isReturnGeneratedKeys); if (connectionMode.equals(ConnectionMode.MEMORY_STRICTLY)) { statement.setFetchSize(MEMORY_FETCH_ONE_ROW_A_TIME); } return new StatementExecuteUnit(routeUnit, statement, connectionMode); } }
@Override public StatementExecuteUnit createStatementExecuteUnit(final Connection connection, final RouteUnit routeUnit, final ConnectionMode connectionMode) throws SQLException { Statement statement = getJdbcExecutorWrapper().createStatement(connection, routeUnit.getSqlUnit(), isReturnGeneratedKeys); if (connectionMode.equals(ConnectionMode.MEMORY_STRICTLY)) { statement.setFetchSize(MEMORY_FETCH_ONE_ROW_A_TIME); } return new StatementExecuteUnit(routeUnit, statement, connectionMode); } }
/** * @throws Exception If failed. */ @Test public void testFetchSize() throws Exception { stmt.setFetchSize(1); ResultSet rs = stmt.executeQuery("select * from TestObject where id > 0"); assertTrue(rs.next()); assertTrue(rs.next()); assertTrue(rs.next()); stmt.setFetchSize(0); }
/** * Ensure that it's possible to execute new query on cancelled statement. * * @throws Exception If failed. */ @Test public void testCancelAnotherStmt() throws Exception { stmt.setFetchSize(10); ResultSet rs = stmt.executeQuery("select * from Integer"); assert rs.next(); stmt.cancel(); ResultSet rs2 = stmt.executeQuery("select * from Integer order by _val"); assert rs2.next() : "The other cursor mustn't be closed"; }
/** * @throws Exception If failed. */ @Test public void testNewQueryTaskFetchSize() throws Exception { stmt.setFetchSize(1); boolean res = stmt.execute("select * from TestObject where id > 0"); assertTrue(res); ResultSet rs = stmt.getResultSet(); assertTrue(rs.next()); assertTrue(rs.next()); assertTrue(rs.next()); stmt.setFetchSize(0); }
/** * Trying to call <code>resultSet.next()</code> on a canceled query. * SQLException with message "The query was cancelled while executing." expected. * * @throws Exception If failed. */ @Test public void testResultSetNextAfterCanceling() throws Exception { stmt.setFetchSize(10); ResultSet rs = stmt.executeQuery("select * from Integer"); assert rs.next(); stmt.cancel(); GridTestUtils.assertThrows(log, () -> { rs.next(); return null; }, SQLException.class, "The query was cancelled while executing."); }
protected void afterCreateStatement(Statement stat, DaoStatement st) throws SQLException { if (st.getContext().getFetchSize() != 0) stat.setFetchSize(st.getContext().getFetchSize()); if (st.getContext().getQueryTimeout() > 0) stat.setQueryTimeout(st.getContext().getQueryTimeout()); } }
/** * Test metrics for JDBC in case not fully resultset is not fully read. * * @throws Exception In case of error. */ @Test public void testJdbcSelectNotFullyFetchedQueryHistory() throws Exception { String qry = "select * from A.String"; try (Connection conn = GridTestUtils.connect(queryNode(), null); Statement stmt = conn.createStatement()) { stmt.setFetchSize(1); ResultSet rs = stmt.executeQuery(qry); assertTrue(rs.next()); checkMetrics(0, 0, 0, 0, true); } }