java.sql.PreparedStatement#setFetchDirection ( )源码实例Demo

下面列出了java.sql.PreparedStatement#setFetchDirection ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gemfirexd-oss   文件: J2EEDataSourceTest.java
private PreparedStatement createFloatStatementForStateChecking(
    int[] parameterExpectedValues, int[] PreparedStatementExpectedValues,
    Connection conn, String sql) 
throws SQLException {
    PreparedStatement s = 
        internalCreateFloatStatementForStateChecking(conn, sql);
    s.setCursorName("StokeNewington");
    s.setFetchDirection(ResultSet.FETCH_REVERSE);
    s.setFetchSize(888);
    s.setMaxFieldSize(317);
    s.setMaxRows(91);

    // PreparedStatement Create        
    assertStatementState(
        parameterExpectedValues, PreparedStatementExpectedValues, s);
    return s;
}
 
源代码2 项目: gemfirexd-oss   文件: J2EEDataSourceTest.java
private PreparedStatement createFloatStatementForStateChecking(
    int[] parameterExpectedValues, int[] PreparedStatementExpectedValues,
    Connection conn, String sql) 
throws SQLException {
    PreparedStatement s = 
        internalCreateFloatStatementForStateChecking(conn, sql);
    s.setCursorName("StokeNewington");
    s.setFetchDirection(ResultSet.FETCH_REVERSE);
    s.setFetchSize(888);
    s.setMaxFieldSize(317);
    s.setMaxRows(91);

    // PreparedStatement Create        
    assertStatementState(
        parameterExpectedValues, PreparedStatementExpectedValues, s);
    return s;
}
 
源代码3 项目: spliceengine   文件: J2EEDataSourceTest.java
private PreparedStatement createFloatStatementForStateChecking(
        int[] parameterExpectedValues, int[] PreparedStatementExpectedValues,
        Connection conn, String sql)
        throws SQLException {
    PreparedStatement s =
            internalCreateFloatStatementForStateChecking(conn, sql);
    s.setCursorName("StokeNewington");
    s.setFetchDirection(ResultSet.FETCH_REVERSE);
    s.setFetchSize(888);
    s.setMaxFieldSize(317);
    s.setMaxRows(91);

    // PreparedStatement Create        
    assertStatementState(
            parameterExpectedValues, PreparedStatementExpectedValues, s);
    return s;
}
 
源代码4 项目: stategen   文件: SqlExecutorHelper.java
public static List<Map> queryForList(Connection conn,String sql,int limit) throws SQLException {
	PreparedStatement ps = conn.prepareStatement(sql.trim());
	ps.setMaxRows(limit);
	ps.setFetchDirection(ResultSet.FETCH_FORWARD);
	ResultSet rs = ps.executeQuery();
	try {
		List result =  toListMap(limit, rs);
		return result;
	}finally {
		DBHelper.close(rs);
	}
}
 
源代码5 项目: hop   文件: Database.java
public ResultSet openQuery( PreparedStatement ps, IRowMeta params, Object[] data )
  throws HopDatabaseException {
  ResultSet res;

  // Create a Statement
  try {
    log.snap( Metrics.METRIC_DATABASE_OPEN_QUERY_START, databaseMeta.getName() );

    log.snap( Metrics.METRIC_DATABASE_SQL_VALUES_START, databaseMeta.getName() );
    setValues( params, data, ps ); // set the parameters!
    log.snap( Metrics.METRIC_DATABASE_SQL_VALUES_STOP, databaseMeta.getName() );

    if ( canWeSetFetchSize( ps ) ) {
      int maxRows = ps.getMaxRows();
      int fs = Const.FETCH_SIZE <= maxRows ? maxRows : Const.FETCH_SIZE;
      // mysql have some restriction on fetch size assignment
      if ( databaseMeta.isMySqlVariant() ) {
        setMysqlFetchSize( ps, fs, maxRows );
      } else {
        // other databases seems not.
        ps.setFetchSize( fs );
      }

      ps.setFetchDirection( ResultSet.FETCH_FORWARD );
    }

    if ( rowlimit > 0 && databaseMeta.supportsSetMaxRows() ) {
      ps.setMaxRows( rowlimit );
    }

    log.snap( Metrics.METRIC_DATABASE_EXECUTE_SQL_START, databaseMeta.getName() );
    res = ps.executeQuery();
    log.snap( Metrics.METRIC_DATABASE_EXECUTE_SQL_STOP, databaseMeta.getName() );

    // MySQL Hack only. It seems too much for the cursor type of operation on
    // MySQL, to have another cursor opened
    // to get the length of a String field. So, on MySQL, we ignore the length
    // of Strings in result rows.
    //
    log.snap( Metrics.METRIC_DATABASE_GET_ROW_META_START, databaseMeta.getName() );
    rowMeta = getRowInfo( res.getMetaData(), databaseMeta.isMySqlVariant(), false );
    log.snap( Metrics.METRIC_DATABASE_GET_ROW_META_STOP, databaseMeta.getName() );
  } catch ( SQLException ex ) {
    throw new HopDatabaseException( "ERROR executing query", ex );
  } catch ( Exception e ) {
    throw new HopDatabaseException( "ERROR executing query", e );
  } finally {
    log.snap( Metrics.METRIC_DATABASE_OPEN_QUERY_STOP, databaseMeta.getName() );
  }

  return res;
}
 
源代码6 项目: skywalking   文件: SwPreparedStatementTest.java
@Test
public void testPreparedStatementConfig() throws SQLException {
    PreparedStatement preparedStatement = swConnection.prepareStatement("INSERT INTO test VALUES( ? , ?)", 1);
    preparedStatement.setInt(1, 1);
    preparedStatement.setString(2, "a");
    preparedStatement.getUpdateCount();
    preparedStatement.setFetchDirection(1);
    preparedStatement.getFetchDirection();
    preparedStatement.getResultSetConcurrency();
    preparedStatement.getResultSetType();
    preparedStatement.isClosed();
    preparedStatement.setPoolable(false);
    preparedStatement.isPoolable();
    preparedStatement.getWarnings();
    preparedStatement.clearWarnings();
    preparedStatement.setCursorName("test");
    preparedStatement.setMaxFieldSize(11);
    preparedStatement.getMaxFieldSize();
    preparedStatement.setMaxRows(10);
    preparedStatement.getMaxRows();
    preparedStatement.getParameterMetaData();
    preparedStatement.setEscapeProcessing(true);
    preparedStatement.setFetchSize(1);
    preparedStatement.getFetchSize();
    preparedStatement.setQueryTimeout(1);
    preparedStatement.getQueryTimeout();
    Connection connection = preparedStatement.getConnection();

    preparedStatement.execute();

    preparedStatement.getMoreResults();
    preparedStatement.getMoreResults(1);
    preparedStatement.getResultSetHoldability();
    preparedStatement.getMetaData();
    preparedStatement.getResultSet();

    preparedStatement.close();
    verify(mysqlPreparedStatement).getUpdateCount();
    verify(mysqlPreparedStatement).getMoreResults();
    verify(mysqlPreparedStatement).setFetchDirection(anyInt());
    verify(mysqlPreparedStatement).getFetchDirection();
    verify(mysqlPreparedStatement).getResultSetType();
    verify(mysqlPreparedStatement).isClosed();
    verify(mysqlPreparedStatement).setPoolable(anyBoolean());
    verify(mysqlPreparedStatement).getWarnings();
    verify(mysqlPreparedStatement).clearWarnings();
    verify(mysqlPreparedStatement).setCursorName(anyString());
    verify(mysqlPreparedStatement).setMaxFieldSize(anyInt());
    verify(mysqlPreparedStatement).getMaxFieldSize();
    verify(mysqlPreparedStatement).setMaxRows(anyInt());
    verify(mysqlPreparedStatement).getMaxRows();
    verify(mysqlPreparedStatement).setEscapeProcessing(anyBoolean());
    verify(mysqlPreparedStatement).getResultSetConcurrency();
    verify(mysqlPreparedStatement).getResultSetConcurrency();
    verify(mysqlPreparedStatement).getResultSetType();
    verify(mysqlPreparedStatement).getMetaData();
    verify(mysqlPreparedStatement).getParameterMetaData();
    verify(mysqlPreparedStatement).getMoreResults(anyInt());
    verify(mysqlPreparedStatement).setFetchSize(anyInt());
    verify(mysqlPreparedStatement).getFetchSize();
    verify(mysqlPreparedStatement).getQueryTimeout();
    verify(mysqlPreparedStatement).setQueryTimeout(anyInt());
    verify(mysqlPreparedStatement).getResultSet();
    assertThat(connection, CoreMatchers.<Connection>is(swConnection));
}
 
源代码7 项目: pentaho-kettle   文件: Database.java
public ResultSet openQuery( PreparedStatement ps, RowMetaInterface params, Object[] data )
  throws KettleDatabaseException {
  ResultSet res;

  // Create a Statement
  try {
    log.snap( Metrics.METRIC_DATABASE_OPEN_QUERY_START, databaseMeta.getName() );

    log.snap( Metrics.METRIC_DATABASE_SQL_VALUES_START, databaseMeta.getName() );
    setValues( params, data, ps ); // set the parameters!
    log.snap( Metrics.METRIC_DATABASE_SQL_VALUES_STOP, databaseMeta.getName() );

    if ( canWeSetFetchSize( ps ) ) {
      int maxRows = ps.getMaxRows();
      int fs = Const.FETCH_SIZE <= maxRows ? maxRows : Const.FETCH_SIZE;
      // mysql have some restriction on fetch size assignment
      if ( databaseMeta.isMySQLVariant() ) {
        setMysqlFetchSize( ps, fs, maxRows );
      } else {
        // other databases seems not.
        ps.setFetchSize( fs );
      }

      ps.setFetchDirection( ResultSet.FETCH_FORWARD );
    }

    if ( rowlimit > 0 && databaseMeta.supportsSetMaxRows() ) {
      ps.setMaxRows( rowlimit );
    }

    log.snap( Metrics.METRIC_DATABASE_EXECUTE_SQL_START, databaseMeta.getName() );
    res = ps.executeQuery();
    log.snap( Metrics.METRIC_DATABASE_EXECUTE_SQL_STOP, databaseMeta.getName() );

    // MySQL Hack only. It seems too much for the cursor type of operation on
    // MySQL, to have another cursor opened
    // to get the length of a String field. So, on MySQL, we ignore the length
    // of Strings in result rows.
    //
    log.snap( Metrics.METRIC_DATABASE_GET_ROW_META_START, databaseMeta.getName() );
    rowMeta = getRowInfo( res.getMetaData(), databaseMeta.isMySQLVariant(), false );
    log.snap( Metrics.METRIC_DATABASE_GET_ROW_META_STOP, databaseMeta.getName() );
  } catch ( SQLException ex ) {
    throw new KettleDatabaseException( "ERROR executing query", ex );
  } catch ( Exception e ) {
    throw new KettleDatabaseException( "ERROR executing query", e );
  } finally {
    log.snap( Metrics.METRIC_DATABASE_OPEN_QUERY_STOP, databaseMeta.getName() );
  }

  return res;
}