Java Code Examples for java.sql.Statement#getMaxRows()

The following examples show how to use java.sql.Statement#getMaxRows() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Database.java    From hop with Apache License 2.0 4 votes vote down vote up
private boolean canWeSetFetchSize( Statement statement ) throws SQLException {
  return databaseMeta.isFetchSizeSupported()
    && ( statement.getMaxRows() > 0
    || databaseMeta.getIDatabase().isPostgresVariant()
    || ( databaseMeta.isMySqlVariant() && databaseMeta.isStreamingResults() ) );
}
 
Example 2
Source File: SWStatementTest.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Test
public void testPreparedStatementConfig() throws SQLException {
    Statement statement = swConnection.createStatement();
    statement.cancel();
    statement.getUpdateCount();
    statement.setFetchDirection(1);
    statement.getFetchDirection();
    statement.getResultSetConcurrency();
    statement.getResultSetType();
    statement.isClosed();
    statement.setPoolable(false);
    statement.isPoolable();
    statement.getWarnings();
    statement.clearWarnings();
    statement.setCursorName("test");
    statement.setMaxFieldSize(11);
    statement.getMaxFieldSize();
    statement.setMaxRows(10);
    statement.getMaxRows();
    statement.setEscapeProcessing(true);
    statement.setFetchSize(1);
    statement.getFetchSize();
    statement.setQueryTimeout(1);
    statement.getQueryTimeout();
    Connection connection = statement.getConnection();

    statement.execute("SELECT * FROM test");
    statement.getMoreResults();
    statement.getMoreResults(1);
    statement.getResultSetHoldability();
    statement.getResultSet();

    statement.close();
    verify(mysqlStatement).getUpdateCount();
    verify(mysqlStatement).getMoreResults();
    verify(mysqlStatement).setFetchDirection(anyInt());
    verify(mysqlStatement).getFetchDirection();
    verify(mysqlStatement).getResultSetType();
    verify(mysqlStatement).isClosed();
    verify(mysqlStatement).setPoolable(anyBoolean());
    verify(mysqlStatement).getWarnings();
    verify(mysqlStatement).clearWarnings();
    verify(mysqlStatement).setCursorName(anyString());
    verify(mysqlStatement).setMaxFieldSize(anyInt());
    verify(mysqlStatement).getMaxFieldSize();
    verify(mysqlStatement).setMaxRows(anyInt());
    verify(mysqlStatement).getMaxRows();
    verify(mysqlStatement).setEscapeProcessing(anyBoolean());
    verify(mysqlStatement).getResultSetConcurrency();
    verify(mysqlStatement).getResultSetConcurrency();
    verify(mysqlStatement).getResultSetType();
    verify(mysqlStatement).getMoreResults(anyInt());
    verify(mysqlStatement).setFetchSize(anyInt());
    verify(mysqlStatement).getFetchSize();
    verify(mysqlStatement).getQueryTimeout();
    verify(mysqlStatement).setQueryTimeout(anyInt());
    verify(mysqlStatement).getResultSet();
    assertThat(connection, CoreMatchers.<Connection>is(swConnection));

    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/execute", "SELECT * FROM test");
}
 
Example 3
Source File: Database.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private boolean canWeSetFetchSize( Statement statement ) throws SQLException {
  return databaseMeta.isFetchSizeSupported()
    && ( statement.getMaxRows() > 0
    || databaseMeta.getDatabaseInterface() instanceof PostgreSQLDatabaseMeta
    || ( databaseMeta.isMySQLVariant() && databaseMeta.isStreamingResults() ) );
}
 
Example 4
Source File: ServerSqlUtil.java    From aceql-http with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
    * Set the maximum rows to return to the client side
    *
    * @param username
    * @param database
    * @param statement            the statement to set
    * @param databaseConfigurator the DatabaseConfigurator which contains the
    *                             getMaxRowsToReturn() method
    *
    *
    * @throws SQLException
    * @throws IOException
    */
   public static void setMaxRowsToReturn(String username, String database, Statement statement,
    DatabaseConfigurator databaseConfigurator) throws SQLException, IOException {

int maxRowsToReturn = databaseConfigurator.getMaxRows(username, database);

if (maxRowsToReturn > 0) {
    if (statement.getMaxRows() == 0 || (statement.getMaxRows() > maxRowsToReturn)) {
	statement.setFetchSize(0); // To avoid any possible conflict
	statement.setMaxRows(maxRowsToReturn);
    }
}
   }