Statement setMaxRows - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Statement setMaxRows method.

This code example shows how to use the following methods:close, executeQuery, setMaxRows
  long getLastEventId() throws SQLException {
    DriverManagerConnectionSource cs = getConnectionSource();
 
    Connection con = cs.getConnection();
    Statement statement = con.createStatement();
    statement.setMaxRows(1);
    ResultSet rs = statement
        .executeQuery("select event_id from logging_event order by event_id desc");
    rs.next();
    long eventId = rs.getLong(1);
    rs.close();
    statement.close();
    return eventId;
  } 
 
  void verify(long lastEventId) throws SQLException {
    verifyDebugMsg(lastEventId);
    verifyException(lastEventId);
    verifyProperty(lastEventId);
 
6
CodeRank
This code example shows how to use the following methods:executeQuery, getLargeMaxRows, getMaxRows, setMaxRows
    @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); 
    } 
 

6
CodeRank
This code example shows how to use the following methods:close, executeQuery, getMaxRows, setMaxRows
        // We should have gotten no warnings and a read only forward only cursor 
        JDBC.assertNoWarnings(conn.getWarnings());
        conn.clearWarnings();
 
        // Verify that setMaxRows(4) succeeds 
        s_f_r.setMaxRows(5);
        assertEquals(5, s_f_r.getMaxRows());
 
        rs = s_f_r.executeQuery("values 1, 2, 3, 4, 5, 6");
        // Iterate straight thru RS, expect only 5 rows. 
        JDBC.assertDrainResults(rs, 5);
         
        s_f_r.close();
 
    } 
 
    /** 
     * Scroll sensitive cursor tests 
     *  
     * This method tests scroll sensitive cursors. (Not implemented, so we 
5
CodeRank
This code example shows how to use the following methods:getMaxRows, getQueryTimeout, setMaxRows, setQueryTimeout
 
	private void closeQueryStatement(PreparedStatement ps) throws SQLException {
 
		try { 
			//work around a bug in all known connection pools.... 
			if ( ps.getMaxRows()!=0 ) ps.setMaxRows(0);
			if ( ps.getQueryTimeout()!=0 ) ps.setQueryTimeout(0);
		} 
		catch (Exception e) {
			log.warn("exception clearing maxRows/queryTimeout", e);
//			ps.close(); //just close it; do NOT try to return it to the pool! 
			return; //NOTE: early exit! 
		} 
		finally { 
			closeStatement(ps);
		} 
 
		if ( lastQuery==ps ) lastQuery = null;
 
	} 
5
CodeRank
This code example shows how to use the following methods:setFetchSize, setMaxRows, setQueryTimeout
   */ 
  protected void setStatementLimitations( Statement stmt ) throws SQLException {
 
    if ( this.getFetchSize() >= 0 ) {
      try { 
        stmt.setFetchSize( this.getFetchSize() );
      } catch ( Exception ex ) {
        if ( ex instanceof SQLException ) {
          throw (SQLException) ex;
        } else { 
          // exception here means either the number was out of bounds or 
          // the driver doesn't support this setter. 
          throw new UnsupportedOperationException( Messages.getInstance().getErrorString(
            "SQLConnection.ERROR_0003_FETCHSIZE_NOT_SET", Integer.toString( this.getFetchSize() ) ), ex ); //$NON-NLS-1$
        } 
      } 
    } 
 
    if ( this.getMaxRows() >= 0 ) {
      try { 

5
CodeRank
This code example shows how to use the following methods:setFetchDirection, setFetchSize, setMaxRows, setQueryTimeout
	 * @see #setMaxRows 
	 * @see #setQueryTimeout 
	 */ 
	protected void applyStatementSettings(PreparedStatement stmt) throws SQLException {
		if (fetchSize != VALUE_NOT_SET) {
			stmt.setFetchSize(fetchSize);
			stmt.setFetchDirection(ResultSet.FETCH_FORWARD);
		} 
		if (maxRows != VALUE_NOT_SET) {
			stmt.setMaxRows(maxRows);
		} 
		if (queryTimeout != VALUE_NOT_SET) {
			stmt.setQueryTimeout(queryTimeout);
		} 
	} 
 
	/** 
	 * Creates a default SQLErrorCodeSQLExceptionTranslator for the specified 
	 * DataSource if none is set. 
	 * 
7
CodeRank
This code example shows how to use the following methods:setMaxRows
        return delegate.getMaxRows();
    } 
 
    @Override 
    public void setMaxRows(int max) throws SQLException {
        delegate.setMaxRows(max);
    } 
 
    @Override 
    public void setEscapeProcessing(boolean enable) throws SQLException {
        delegate.setEscapeProcessing(enable);
    } 
 
    @Override 
    public int getQueryTimeout() throws SQLException {
        return delegate.getQueryTimeout();
    } 
 
    @Override 
    public void setQueryTimeout(int seconds) throws SQLException {
5
CodeRank
This code example shows how to use the following methods:setMaxRows
            try { 
                final PreparedStatement sql = sqlSchema.sql_getFetchAll(
                        connection,
                        batchWhereClause,
                        params.toArray()); 
                sql.setMaxRows(batchSize);
                return new PreparedStatementIterator<T>(sql, sqlSchema);
            } catch (SQLException e) {
                throw new EventStoreException("Exception occurred while attempting to execute prepared statement", e);
            } 
        } 
 
        private String buildWhereClause(List<Object> params) {
            if (lastItem == null && whereClause == null) {
                return ""; 
            } 
            StringBuilder sb = new StringBuilder();
            if (lastItem != null) {
                sb.append("(")
                  .append("(e.timeStamp > ?)")
5
CodeRank
This code example shows how to use the following methods:executeQuery, setMaxRows
		this.limit = limit;
		this.rowMapper = rowMapper;
	} 
 
	public Object doInPreparedStatement(PreparedStatement ps)throws SQLException, DataAccessException {
		ps.setMaxRows(limit);
		ResultSet rs = null;
		try { 
			rs = ps.executeQuery();
			OffsetLimitResultSetExtractor rse = new OffsetLimitResultSetExtractor(offset,limit,rowMapper);
			return (List)rse.extractData(rs);
		}finally { 
			JdbcUtils.closeResultSet(rs);
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:setMaxRows
 
	public void setMaxRows(int arg0) throws SQLException {
 
		try { 
 
			pstmt.setMaxRows(arg0);
 
		} catch (SQLException e) {
 
			this.abort();
			throw e;
		} 
	} 
 
	public void setNull(int arg0, int arg1, String arg2) throws SQLException {
 
		try { 
 
			pstmt.setNull(arg0, arg1, arg2);
 
4
CodeRank
setMaxRows Method Overview
Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number.
See Code Examples for other Java 8 Statement Methods: