@Override public void execute(final Statement statement) throws SQLException { statement.setMaxRows(max); } });
@Override public void setMaxRows(int max) throws SQLException { targetStatement.setMaxRows(max); }
@Override public void setMaxRows(int max) throws SQLException { statement.setMaxRows(max); }
@Override public void setMaxRows(int max) throws SQLException { delegate.setMaxRows(max); }
public void setMaxRows(int max) throws SQLException { stmt.setMaxRows(max); }
@Override public Object call() throws Exception { stmt.setMaxRows(-1); return null; } },
protected void processStatementAttr(Statement s, SQLRequest sqlRequest) throws SQLException { Integer statementMaxRows = BackdoorToggles.getStatementMaxRows(); if (statementMaxRows != null) { logger.info("Setting current statement's max rows to {}", statementMaxRows); s.setMaxRows(statementMaxRows); } }
@Override public void run() throws Exception { stmt.setMaxRows(maxRows); } });
@Override public void setMaxRows(int max) throws SQLException { checkOpen(); try { stmt.setMaxRows(max); } catch (Throwable t) { throw checkException(t); } }
@Override protected ResultSet runQuery(Connection connection) throws SQLException { statement = getStatement(connection, sql); if (getMaxRows() != 0) statement.setMaxRows(getMaxRows()); return statement.executeQuery(sql); } }
@Override protected ResultSet runQuery(Connection connection) throws SQLException { PreparedStatement s = getPreparedStatement(connection, sql, params); statement = s; if (getMaxRows() != 0) statement.setMaxRows(getMaxRows()); return s.executeQuery(); } }
@Override public void statement_setMaxRows(StatementProxy statement, int max) throws SQLException { if (this.pos < filterSize) { nextFilter().statement_setMaxRows(this, statement, max); return; } statement.getRawObject().setMaxRows(max); }
/** * 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()); }
private void testAvaticaQuery(String url) { LOG.info("URL: " + url); try { Properties connectionProperties = new Properties(); connectionProperties.put("user", "admin"); connectionProperties.put("password", "priest"); Connection connection = DriverManager.getConnection(url, connectionProperties); Statement statement = connection.createStatement(); statement.setMaxRows(450); String query = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS"; ResultSet resultSet = statement.executeQuery(query); Assert.assertTrue(resultSet.next()); statement.close(); connection.close(); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Sets the limit for the maximum number of rows that any ResultSet object can contain to the given number. * If the limit is exceeded, the excess rows are silently dropped. Zero means there is no limit. * @see Statement#setMaxRows(int) */ public Q setMaxRows(final int maxRows) { checkNotClosed(); this.maxRows = maxRows; if (statement != null) { try { statement.setMaxRows(maxRows); } catch (SQLException sex) { throw new DbSqlException(this, "Unable to set max rows: " + maxRows, sex); } } return _this(); }
private void testAvaticaAuthFailure(String url) throws Exception { LOG.info("URL: " + url); try { Properties connectionProperties = new Properties(); connectionProperties.put("user", "admin"); connectionProperties.put("password", "wrongpassword"); Connection connection = DriverManager.getConnection(url, connectionProperties); Statement statement = connection.createStatement(); statement.setMaxRows(450); String query = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS"; statement.executeQuery(query); } catch (AvaticaSqlException ase) { Assert.assertEquals( ase.getErrorMessage(), "Error while executing SQL \"SELECT * FROM INFORMATION_SCHEMA.COLUMNS\": Remote driver error: ForbiddenException: Authentication failed." ); return; } Assert.fail("Test failed, did not get AvaticaSqlException."); }
statement.setMaxRows( 0 );
@Test public void testMaxRowsUnlimited() throws SQLException { assertMaxRowsLimit(0); statement.setMaxRows(0); assertMaxRowsLimit(0); assertMaxRowsResult(7); }
@Test public void testMaxRowsLimited() throws SQLException { assertMaxRowsLimit(0); statement.setMaxRows(4); assertMaxRowsLimit(4); assertMaxRowsResult(4); }
@Test public void testMaxRowsLimitLargerThanResult() throws SQLException { assertMaxRowsLimit(0); statement.setMaxRows(10); assertMaxRowsLimit(10); assertMaxRowsResult(7); }