Statement setFetchSize - 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 setFetchSize method.

This code example shows how to use the following methods:executeQuery, setLong, setFetchDirection, setFetchSize
    PreparedStatement stmt = null;
    ResultSet rs = null;
    try { 
      conn = dataSource.getConnection();
      stmt = conn.prepareStatement(getStringIDSQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      stmt.setFetchDirection(ResultSet.FETCH_FORWARD);
      stmt.setFetchSize(1);
      stmt.setLong(1, longID);
      rs = stmt.executeQuery();
      if (rs.next()) {
        return rs.getString(1);
      } else { 
        return null; 
      } 
    } catch (SQLException sqle) {
      throw new TasteException(sqle);
    } finally { 
      IOUtils.quietClose(rs, stmt, conn);
    } 
  } 

7
CodeRank
This code example shows how to use the following methods:executeQuery, setLong, setFetchDirection, setFetchSize
    Connection conn = null;
    PreparedStatement stmt = null;
    try { 
      conn = dataSource.getConnection();
      stmt = conn.prepareStatement(getItemItemSimilaritySQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      stmt.setFetchDirection(ResultSet.FETCH_FORWARD);
      stmt.setFetchSize(getFetchSize());
      return doItemSimilarity(stmt, itemID1, itemID2);
    } catch (SQLException sqle) {
      log.warn("Exception while retrieving similarity", sqle);
      throw new TasteException(sqle);
    } finally { 
      IOUtils.quietClose(null, stmt, conn);
    } 
  } 
 
  @Override 
  public double[] itemSimilarities(long itemID1, long[] itemID2s) throws TasteException {
    double[] result = new double[itemID2s.length];
    Connection conn = null;

7
CodeRank
This code example shows how to use the following methods:close, setFetchSize, setQueryTimeout
 
  protected void setStatementTimeout(Statement stmt) throws SQLException {
    Integer timeout = mappedStatement.getTimeout();
    Integer defaultTimeout = configuration.getDefaultStatementTimeout();
    if (timeout != null) {
      stmt.setQueryTimeout(timeout);
    } else if (defaultTimeout != null) {
      stmt.setQueryTimeout(defaultTimeout);
    } 
  } 
 
  protected void setFetchSize(Statement stmt) throws SQLException {
    Integer fetchSize = mappedStatement.getFetchSize();
    if (fetchSize != null) {
      stmt.setFetchSize(fetchSize);
    } 
  } 
 
  protected void closeStatement(Statement statement) {
    try { 

6
CodeRank
This code example shows how to use the following methods:executeQuery, setLong, setFetchDirection, setFetchSize
    Connection conn = null;
    PreparedStatement stmt = null;
    try { 
      conn = dataSource.getConnection();
      stmt = conn.prepareStatement(getItemItemSimilaritySQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      stmt.setFetchDirection(ResultSet.FETCH_FORWARD);
      stmt.setFetchSize(getFetchSize());
      return doItemSimilarity(stmt, itemID1, itemID2);
    } catch (SQLException sqle) {
      log.warn("Exception while retrieving similarity", sqle);
      throw new TasteException(sqle);
    } finally { 
      IOUtils.quietClose(null, stmt, conn);
    } 
  } 
 
  @Override 
  public double[] itemSimilarities(long itemID1, long[] itemID2s) throws TasteException {
    double[] result = new double[itemID2s.length];
    Connection conn = null;

8
CodeRank
This code example shows how to use the following methods:close, getFetchDirection, getFetchSize, getResultSetConcurrency, getResultSetType
6
CodeRank
This code example shows how to use the following methods:setFetchDirection, setFetchSize
 
    @Override 
    public Statement createReadStatement(Connection dataConn) throws SQLException {
        Statement st = super.createReadStatement(dataConn);
 
        st.setFetchDirection(ResultSet.FETCH_FORWARD);
        st.setFetchSize(Integer.MIN_VALUE);
 
        return st;
    } 
 
    public String getDatabase() {
        return database;
    } 
 
    public void setDatabase(String database) {
        this.database = database;
    } 
 
    public String getPassword() {
5
CodeRank
This code example shows how to use the following methods:executeQuery, setFetchSize
        this.url = properties.getString(ReplicatorConf.THL_DB_URL);
        this.user = properties.getString(ReplicatorConf.THL_DB_USER);
        this.password = properties.getString(ReplicatorConf.THL_DB_PASSWORD);
 
        // Create version table if it does not exist. 
        Table version = Version.getVersionTableDefinition(this.metadataSchema);
        connect(url, user, password);
        conn.createTable(version, false, properties.getString(
                ReplicatorConf.METADATA_TABLE_TYPE, 
                ReplicatorConf.METADATA_TABLE_TYPE_DEFAULT, false)); 
        disconnect(); 
    } 
 
    public Version getVersion(String module) throws SQLException
    { 
        Version ret = null;
 
        connect(url, user, password);
 
        try 

5
CodeRank
This code example shows how to use the following methods:executeQuery, setLong, setFetchDirection, setFetchSize
    PreparedStatement stmt = null;
    ResultSet rs = null;
    try { 
      conn = dataSource.getConnection();
      stmt = conn.prepareStatement(getStringIDSQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      stmt.setFetchDirection(ResultSet.FETCH_FORWARD);
      stmt.setFetchSize(1);
      stmt.setLong(1, longID);
      rs = stmt.executeQuery();
      if (rs.next()) {
        return rs.getString(1);
      } else { 
        return null; 
      } 
    } catch (SQLException sqle) {
      throw new TasteException(sqle);
    } finally { 
      IOUtils.quietClose(rs, stmt, conn);
    } 
  } 

8
CodeRank
This code example shows how to use the following methods:executeQuery, setFetchSize
    public static Version getVersionFromDB(Statement statement, String schema,
            String module) throws SQLException
    { 
        Version ret = null;
 
        statement.setFetchSize(1);
        ResultSet rs = null;
 
        try 
        { 
            rs = statement.executeQuery(constructSelect(schema, module));
            if (rs.next())
            { 
                int major = rs.getInt(MAJOR_COLUMN);
                int minor = rs.getInt(MINOR_COLUMN);
                String suffix = rs.getString(SUFFIX_COLUMN);
                ret = new Version(major, minor, suffix);
            } 
        } 
        finally 
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
setFetchSize Method Overview
Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for ResultSet objects generated by this Statement.
See Code Examples for other Java 8 Statement Methods: