Java Code Examples for java.sql.ResultSet#TYPE_SCROLL_SENSITIVE
The following examples show how to use
java.sql.ResultSet#TYPE_SCROLL_SENSITIVE .
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: CassandraStatement.java From cassandra-jdbc-wrapper with Apache License 2.0 | 6 votes |
CassandraStatement(CassandraConnection con, String cql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { this.connection = con; this.cql = cql; this.batchQueries = Lists.newArrayList(); this.consistencyLevel = con.defaultConsistencyLevel; if (!(resultSetType == ResultSet.TYPE_FORWARD_ONLY || resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE || resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)) throw new SQLSyntaxErrorException(BAD_TYPE_RSET); this.resultSetType = resultSetType; if (!(resultSetConcurrency == ResultSet.CONCUR_READ_ONLY || resultSetConcurrency == ResultSet.CONCUR_UPDATABLE)) throw new SQLSyntaxErrorException(BAD_TYPE_RSET); this.resultSetConcurrency = resultSetConcurrency; if (!(resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT || resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT)) throw new SQLSyntaxErrorException(BAD_HOLD_RSET); this.resultSetHoldability = resultSetHoldability; }
Example 2
Source File: GFXDServiceImpl.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Returns the resultType if set if not set returns the default * java.sql.ResultSet.TYPE_FORWARD_ONLY */ static int getResultType(StatementAttrs attrs) { int rsType; if (attrs != null && attrs.isSetResultSetType()) { rsType = attrs.getResultSetType(); } else { rsType = gfxdConstants.DEFAULT_RESULTSET_TYPE; } switch (rsType) { case gfxdConstants.RESULTSET_TYPE_FORWARD_ONLY: return ResultSet.TYPE_FORWARD_ONLY; case gfxdConstants.RESULTSET_TYPE_INSENSITIVE: return ResultSet.TYPE_SCROLL_INSENSITIVE; case gfxdConstants.RESULTSET_TYPE_SENSITIVE: return ResultSet.TYPE_SCROLL_SENSITIVE; default: throw new InternalGemFireError("unknown resultSet type " + attrs.getResultSetType()); } }
Example 3
Source File: EmbedConnection.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private int setResultSetType(int resultSetType) { /* Add warning if scroll sensitive cursor * and downgrade to scroll insensitive cursor. */ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) { addWarning(SQLWarningFactory.newSQLWarning(SQLState.NO_SCROLL_SENSITIVE_CURSORS)); resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE; } return resultSetType; }
Example 4
Source File: IoTDBConnection.java From incubator-iotdb with Apache License 2.0 | 5 votes |
@Override public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) { throw new SQLException( String.format("Statements with result set concurrency %d are not supported", resultSetConcurrency)); } if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) { throw new SQLException(String.format("Statements with ResultSet type %d are not supported", resultSetType)); } return new IoTDBStatement(this, getClient(), sessionId, zoneId); }
Example 5
Source File: CommonRowSetTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "rowSetScrollTypes") protected Object[][] rowSetScrollTypes() throws Exception { RowSet rs = newInstance(); return new Object[][]{ {rs, ResultSet.TYPE_FORWARD_ONLY}, {rs, ResultSet.TYPE_SCROLL_INSENSITIVE}, {rs, ResultSet.TYPE_SCROLL_SENSITIVE} }; }
Example 6
Source File: EmbedDatabaseMetaData.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * JDBC 2.0 * * Does the database support the concurrency type in combination * with the given result set type? * * @param type defined in java.sql.ResultSet * @param concurrency type defined in java.sql.ResultSet * @return true if so * @see Connection */ public boolean supportsResultSetConcurrency(int type, int concurrency) { if (type == ResultSet.TYPE_SCROLL_SENSITIVE) { // (TYPE_SCROLL_SENSITIVE, *) return false; } else { // (FORWARD_ONLY, CONCUR_UPDATABLE) // (FORWARD_ONLY, CONCUR_READ_ONLY) // (TYPE_SCROLL_INSENSITIVE, CONCUR_UPDATABLE) // (TYPE_SCROLL_INSENSITIVE, READ_ONLY) return true; } }
Example 7
Source File: SQLExecutionHelper.java From netbeans with Apache License 2.0 | 5 votes |
/** * Determine if DBMS/Driver supports scrollable resultsets to be able to * determine complete row count for a given SQL. * * @param conn established JDBC connection * @param dc connection information * @param sql the sql to be executed */ private void updateScrollableSupport(Connection conn, DatabaseConnection dc, String sql) { useScrollableCursors = dc.isUseScrollableCursors(); if (!useScrollableCursors) { return; } String driverName = dc.getDriverClass(); /* Derby fails to support scrollable cursors when invoking 'stored procedures' which return resultsets - it fails hard: not throwing a SQLException, but terminating the connection - so don't try to use scrollable cursor on derby, for "non"-selects */ if (driverName != null && driverName.startsWith("org.apache.derby")) { //NOI18N if (!isSelectStatement(sql)) { resultSetScrollType = ResultSet.TYPE_FORWARD_ONLY; return; } } /* Try to get a "good" scrollable ResultSet and follow the DBs support */ try { if (conn.getMetaData().supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE)) { resultSetScrollType = ResultSet.TYPE_SCROLL_INSENSITIVE; } else if (conn.getMetaData().supportsResultSetType( ResultSet.TYPE_SCROLL_SENSITIVE)) { resultSetScrollType = ResultSet.TYPE_SCROLL_SENSITIVE; } } catch (Exception ex) { LOGGER.log(Level.WARNING, "Exception while querying" //NOI18N + " database for scrollable resultset support"); //NOI18N } }
Example 8
Source File: CommonRowSetTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "rowSetScrollTypes") protected Object[][] rowSetScrollTypes() throws Exception { RowSet rs = newInstance(); return new Object[][]{ {rs, ResultSet.TYPE_FORWARD_ONLY}, {rs, ResultSet.TYPE_SCROLL_INSENSITIVE}, {rs, ResultSet.TYPE_SCROLL_SENSITIVE} }; }
Example 9
Source File: CommonRowSetTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "rowSetScrollTypes") protected Object[][] rowSetScrollTypes() throws Exception { RowSet rs = newInstance(); return new Object[][]{ {rs, ResultSet.TYPE_FORWARD_ONLY}, {rs, ResultSet.TYPE_SCROLL_INSENSITIVE}, {rs, ResultSet.TYPE_SCROLL_SENSITIVE} }; }
Example 10
Source File: QueryExecuter.java From barleydb with GNU Lesser General Public License v3.0 | 5 votes |
private static int getResultSetType(RuntimeProperties props) throws BarleyDBQueryException { if (props.getScrollType() == null) { return ResultSet.TYPE_FORWARD_ONLY; } switch(props.getScrollType()) { case FORWARD_ONLY: return ResultSet.TYPE_FORWARD_ONLY; case SCROLL_INSENSITIVE: return ResultSet.TYPE_SCROLL_INSENSITIVE; case SCROLL_SENSITIVE: return ResultSet.TYPE_SCROLL_SENSITIVE; default: throw new IllegalQueryStateException("Unknown scroll type '" + props.getScrollType() + "'"); } }
Example 11
Source File: ClickHouseConnectionImpl.java From clickhouse-jdbc with Apache License 2.0 | 5 votes |
@Override public ClickHouseStatement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY || resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) { throw new SQLFeatureNotSupportedException(); } return createStatement(resultSetType); }
Example 12
Source File: Converters.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static int getJdbcResultSetType(byte thriftType) { switch (thriftType) { case gfxdConstants.RESULTSET_TYPE_FORWARD_ONLY: return ResultSet.TYPE_FORWARD_ONLY; case gfxdConstants.RESULTSET_TYPE_INSENSITIVE: return ResultSet.TYPE_SCROLL_INSENSITIVE; case gfxdConstants.RESULTSET_TYPE_SENSITIVE: return ResultSet.TYPE_SCROLL_SENSITIVE; default: throw new IllegalArgumentException("Thrift ResultSet type=" + thriftType); } }
Example 13
Source File: EmbedConnection.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private int setResultSetType(int resultSetType) { /* Add warning if scroll sensitive cursor * and downgrade to scroll insensitive cursor. */ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) { addWarning(SQLWarningFactory.newSQLWarning(SQLState.NO_SCROLL_SENSITIVE_CURSORS)); resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE; } return resultSetType; }
Example 14
Source File: EmbedDatabaseMetaData.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * JDBC 2.0 * * Does the database support the concurrency type in combination * with the given result set type? * * @param type defined in java.sql.ResultSet * @param concurrency type defined in java.sql.ResultSet * @return true if so * @see Connection */ public boolean supportsResultSetConcurrency(int type, int concurrency) { if (type == ResultSet.TYPE_SCROLL_SENSITIVE) { // (TYPE_SCROLL_SENSITIVE, *) return false; } else { // (FORWARD_ONLY, CONCUR_UPDATABLE) // (FORWARD_ONLY, CONCUR_READ_ONLY) // (TYPE_SCROLL_INSENSITIVE, CONCUR_UPDATABLE) // (TYPE_SCROLL_INSENSITIVE, READ_ONLY) return true; } }
Example 15
Source File: EmbedConnection.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private int setResultSetType(int resultSetType) { /* Add warning if scroll sensitive cursor * and downgrade to scroll insensitive cursor. */ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) { addWarning(SQLWarningFactory.newSQLWarning(SQLState.NO_SCROLL_SENSITIVE_CURSORS)); resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE; } return resultSetType; }
Example 16
Source File: CsvResultSet.java From jdbc-driver-csv with GNU Lesser General Public License v3.0 | 4 votes |
private boolean isScrollable() { return (this.resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE || this.resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE); }
Example 17
Source File: VTIDeferModPolicy.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * See if a VTI modification statement should be deferred. * * @param statementType DeferModification.INSERT_STATEMENT, UPDATE_STATEMENT, or DELETE_STATEMENT * @param targetVTI The target VTI * @param updateColumnNames The list of columns being updated, null if this is not an update statement * @param source */ public static boolean deferIt( int statementType, FromVTI targetVTI, String[] updateColumnNames, QueryTreeNode source) throws StandardException { try { DeferModification deferralControl; int resultSetType = targetVTI.getResultSetType( ); /* Deferred updates and deletes are implemented by scrolling the result set. So, if * the statement is an update or delete but the result set is not scrollable then do * not attempt to defer the statement. */ if( (statementType == DeferModification.UPDATE_STATEMENT ||statementType == DeferModification.DELETE_STATEMENT) && resultSetType == ResultSet.TYPE_FORWARD_ONLY) return false; deferralControl = targetVTI.getDeferralControl(); if( deferralControl == null) { String VTIClassName = targetVTI.getMethodCall().getJavaClassName(); deferralControl = new DefaultVTIModDeferPolicy( VTIClassName, ResultSet.TYPE_SCROLL_SENSITIVE == resultSetType); } if( deferralControl.alwaysDefer( statementType)) return true; if( source == null && statementType != DeferModification.UPDATE_STATEMENT) return false; VTIDeferModPolicy deferralSearch = new VTIDeferModPolicy( targetVTI, updateColumnNames, deferralControl, statementType); if( source != null) source.accept( deferralSearch); if( statementType == DeferModification.UPDATE_STATEMENT) { // Apply the columnRequiresDefer method to updated columns not in the where clause. Enumeration columns = deferralSearch.columns.keys(); while( columns.hasMoreElements()) { if( deferralControl.columnRequiresDefer( statementType, (String) columns.nextElement(), false)) return true; } } return deferralSearch.deferred; } catch( SQLException sqle) { throw StandardException.unexpectedUserException(sqle); } }
Example 18
Source File: VTIDeferModPolicy.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * See if a VTI modification statement should be deferred. * * @param statementType DeferModification.INSERT_STATEMENT, UPDATE_STATEMENT, or DELETE_STATEMENT * @param targetVTI The target VTI * @param updateColumnNames The list of columns being updated, null if this is not an update statement * @param source */ public static boolean deferIt( int statementType, FromVTI targetVTI, String[] updateColumnNames, QueryTreeNode source) throws StandardException { try { DeferModification deferralControl; int resultSetType = targetVTI.getResultSetType( ); /* Deferred updates and deletes are implemented by scrolling the result set. So, if * the statement is an update or delete but the result set is not scrollable then do * not attempt to defer the statement. */ if( (statementType == DeferModification.UPDATE_STATEMENT ||statementType == DeferModification.DELETE_STATEMENT) && resultSetType == ResultSet.TYPE_FORWARD_ONLY) return false; deferralControl = targetVTI.getDeferralControl(); if( deferralControl == null) { String VTIClassName = targetVTI.getMethodCall().getJavaClassName(); deferralControl = new DefaultVTIModDeferPolicy( VTIClassName, ResultSet.TYPE_SCROLL_SENSITIVE == resultSetType); } if( deferralControl.alwaysDefer( statementType)) return true; if( source == null && statementType != DeferModification.UPDATE_STATEMENT) return false; VTIDeferModPolicy deferralSearch = new VTIDeferModPolicy( targetVTI, updateColumnNames, deferralControl, statementType); if( source != null) source.accept( deferralSearch); if( statementType == DeferModification.UPDATE_STATEMENT) { // Apply the columnRequiresDefer method to updated columns not in the where clause. Enumeration columns = deferralSearch.columns.keys(); while( columns.hasMoreElements()) { if( deferralControl.columnRequiresDefer( statementType, (String) columns.nextElement(), false)) return true; } } return deferralSearch.deferred; } catch( SQLException sqle) { throw StandardException.unexpectedUserException(sqle); } }
Example 19
Source File: AbstractStatement.java From sis with Apache License 2.0 | 4 votes |
/** * Default to {@link ResultSet#TYPE_SCROLL_SENSITIVE}, meaning that a change in the underlying * database may affect the result set. */ @Override public int getResultSetType() throws SQLException { return ResultSet.TYPE_SCROLL_SENSITIVE; }
Example 20
Source File: SQLExecutionHelper.java From netbeans with Apache License 2.0 | 4 votes |
private void loadDataFrom(final DataViewPageContext pageContext, ResultSet rs) throws SQLException, InterruptedException { if (rs == null) { return; } int pageSize = pageContext.getPageSize(); int startFrom; if (useScrollableCursors ) { startFrom = pageContext.getCurrentPos(); // will use rs.absolute } else if (!limitSupported || isLimitUsedInSelect(dataView.getSQLString())) { startFrom = pageContext.getCurrentPos(); // need to use slow skip } else { startFrom = 0; // limit added to select, can start from first item } final List<Object[]> rows = new ArrayList<>(); int colCnt = pageContext.getTableMetaData().getColumnCount(); int curRowPos = 0; try { long start = System.currentTimeMillis(); boolean hasNext = false; boolean needSlowSkip = true; if (useScrollableCursors && (rs.getType() == ResultSet.TYPE_SCROLL_INSENSITIVE || rs.getType() == ResultSet.TYPE_SCROLL_SENSITIVE)) { try { hasNext = rs.absolute(startFrom); curRowPos = rs.getRow(); needSlowSkip = false; } catch (SQLException ex) { LOGGER.log(Level.FINE, "Absolute positioning failed", ex); // NOI18N } } if (needSlowSkip) { // Skip till current position hasNext = rs.next(); curRowPos++; while (hasNext && curRowPos < startFrom) { if (Thread.interrupted()) { throw new InterruptedException(); } hasNext = rs.next(); curRowPos++; } } // Get next page int rowCnt = 0; while (((pageSize <= 0) || (pageSize > rowCnt)) && (hasNext)) { if (Thread.interrupted()) { throw new InterruptedException(); } Object[] row = new Object[colCnt]; for (int i = 0; i < colCnt; i++) { row[i] = DBReadWriteHelper.readResultSet(rs, pageContext.getTableMetaData().getColumn(i), i + 1); } rows.add(row); rowCnt++; try { hasNext = rs.next(); curRowPos++; } catch (SQLException x) { LOGGER.log(Level.INFO, "Failed to forward to next record, cause: " + x.getLocalizedMessage(), x); hasNext = false; } } long end = System.currentTimeMillis(); dataView.addFetchTime(end - start); } catch (SQLException e) { LOGGER.log(Level.INFO, "Failed to set up table model.", e); // NOI18N throw e; } finally { Mutex.EVENT.writeAccess(new Runnable() { @Override public void run() { pageContext.getModel().setData(rows); pageContext.getModel().setRowOffset(pageContext.getCurrentPos() - 1); } }); } }