java.sql.ResultSet#HOLD_CURSORS_OVER_COMMIT源码实例Demo

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

源代码1 项目: spliceengine   文件: StatementPoolingTest.java
/**
 * Tests if the holdability settings is taking effect, and also that the
 * result set is closed when the connection is closed.
 *
 * @param holdability result set holdability as specfied by
 *      {@link java.sql.ResultSet}
 * @throws SQLException if something goes wrong...
 */
private void doTestResultSetCloseForHoldability(int holdability)
        throws SQLException {
    getConnection().setAutoCommit(false);
    PreparedStatement ps = prepareStatement(
            "select * from stmtpooltest order by val",
            ResultSet.TYPE_FORWARD_ONLY,
            ResultSet.CONCUR_READ_ONLY,
            holdability);
    ResultSet rs = ps.executeQuery();
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));
    commit();
    if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) {
        assertTrue(rs.next());
        assertEquals(2, rs.getInt(1));
        rollback();
    }
    getConnection().close();
    try {
        rs.next();
        fail("Should have thrown exception");
    } catch (SQLException sqle) {
        assertSQLState("XCL16", sqle);
    }
}
 
源代码2 项目: spliceengine   文件: DRDAStatement.java
private  void parsePkgidToFindHoldability()
{
	if (withHoldCursor != -1)
		return;
       
	//First, check if holdability was passed as a SQL attribute "WITH HOLD" for this prepare. If yes, then withHoldCursor
	//should not get overwritten by holdability from package name and that is why the check for -1
       String pkgid = pkgnamcsn.getPkgid();
	if (isDynamicPkgid(pkgid))
	{       
		if(pkgid.charAt(4) == 'N')
			withHoldCursor = ResultSet.CLOSE_CURSORS_AT_COMMIT;
		else  
			withHoldCursor = ResultSet.HOLD_CURSORS_OVER_COMMIT;
	}
	else 
	{            
		withHoldCursor = ResultSet.HOLD_CURSORS_OVER_COMMIT;
	
	}
}
 
源代码3 项目: iaf   文件: JdbcFacade.java
public String getDatasourceInfo() throws JdbcException {
	String dsinfo=null;
	try (Connection conn=getConnection()) {
		DatabaseMetaData md=conn.getMetaData();
		String product=md.getDatabaseProductName();
		String productVersion=md.getDatabaseProductVersion();
		String driver=md.getDriverName();
		String driverVersion=md.getDriverVersion();
		String url=md.getURL();
		String user=md.getUserName();
		if (getDatabaseType() == DbmsSupportFactory.DBMS_DB2 && "WAS".equals(IbisContext.getApplicationServerType()) && md.getResultSetHoldability() != ResultSet.HOLD_CURSORS_OVER_COMMIT) {
			// For (some?) combinations of WebShere and DB2 this seems to be
			// the default and result in the following exception when (for
			// example?) a ResultSetIteratingPipe is calling next() on the
			// ResultSet after it's sender has called a pipeline which
			// contains a GenericMessageSendingPipe using
			// transactionAttribute="NotSupported":
			//   com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: ResultSet is closed.
			ConfigurationWarnings.add(this, log, "The database's default holdability for ResultSet objects is " + md.getResultSetHoldability() + " instead of " + ResultSet.HOLD_CURSORS_OVER_COMMIT + " (ResultSet.HOLD_CURSORS_OVER_COMMIT)");
		}
		dsinfo ="user ["+user+"] url ["+url+"] product ["+product+"] version ["+productVersion+"] driver ["+driver+"] version ["+driverVersion+"]";
	} catch (SQLException e) {
		log.warn("Exception determining databaseinfo",e);
	}
	return dsinfo;
}
 
void resetRealConnection() throws SQLException {

		// ensure any outstanding changes from the previous
		// user are rolledback.
		realConnection.rollback();

		// clear any warnings that are left over
		realConnection.clearWarnings();

		// need to reset transaction isolation, autocommit, readonly, holdability states
		if (realConnection.getTransactionIsolation() != defaultIsolationLevel) {

			realConnection.setTransactionIsolation(defaultIsolationLevel);
		}

		if (!realConnection.getAutoCommit())
			realConnection.setAutoCommit(true);

		if (realConnection.isReadOnly() != defaultReadOnly)
			realConnection.setReadOnly(defaultReadOnly);

		if (realConnection.getHoldability() != ResultSet.HOLD_CURSORS_OVER_COMMIT)
			realConnection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);

		// reset any remaining state of the connection
		realConnection.resetFromPool();
		if (SanityManager.DEBUG)
		{
			SanityManager.ASSERT(realConnection.transactionIsIdle(),
			"real connection should have been idle at this point"); 			
		}
	}
 
源代码5 项目: jaybird   文件: OOConnection.java
public OOConnection(FBManagedConnection mc) {
    super(mc);
    try {
        super.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
    } catch (SQLException e) {
        // ignore
        log.debug("Unexpected exception setting holdability", e);
    }
}
 
@Override protected Statement newInstance() throws Exception {
  UnregisteredDriver driver = new TestDriver();
  AvaticaConnection connection = new AvaticaConnection(driver, driver.createFactory(),
      "jdbc:avatica", new Properties()) {
  };
  StatementHandle handle = mock(StatementHandle.class);
  AvaticaStatement statement = new AvaticaStatement(connection, handle,
      ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
      ResultSet.HOLD_CURSORS_OVER_COMMIT) {
  };
  statement.close();
  assertTrue("Statement is not closed", statement.isClosed());

  return statement;
}
 
void resetRealConnection() throws SQLException {

		// ensure any outstanding changes from the previous
		// user are rolledback.
		realConnection.rollback();

		// clear any warnings that are left over
		realConnection.clearWarnings();

		// need to reset transaction isolation, autocommit, readonly, holdability states
		if (realConnection.getTransactionIsolation() != defaultIsolationLevel) {

			realConnection.setTransactionIsolation(defaultIsolationLevel);
		}

		if (!realConnection.getAutoCommit())
			realConnection.setAutoCommit(true);

		if (realConnection.isReadOnly() != defaultReadOnly)
			realConnection.setReadOnly(defaultReadOnly);

		if (realConnection.getHoldability() != ResultSet.HOLD_CURSORS_OVER_COMMIT)
			realConnection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);

		// reset any remaining state of the connection
		realConnection.resetFromPool();
		if (SanityManager.DEBUG)
		{
			SanityManager.ASSERT(realConnection.transactionIsIdle(),
			"real connection should have been idle at this point"); 			
		}
	}
 
源代码8 项目: gemfirexd-oss   文件: StatementKeyFactoryTest.java
public void testCallableVsPrepared() {
    String sql = "select colA, colB from mytable";
    String schema = "SOMEAPP";
    int holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
    StatementKey callable =
            StatementKeyFactory.newCallable(sql, schema, holdability);
    StatementKey prepared =
            StatementKeyFactory.newPrepared(sql, schema, holdability);
    assertFalse(callable.equals(prepared));
    assertFalse(prepared.equals(callable));
}
 
源代码9 项目: gemfirexd-oss   文件: StatementKeyFactoryTest.java
public void testEqualityDefaultNoAutoGenKey() {
    int holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
    StatementKey basicKey = StatementKeyFactory.newPrepared(
            "values 2", "APP", holdability);
    StatementKey simplifiedKey = StatementKeyFactory.newPrepared(
            "values 2", "APP", holdability, Statement.NO_GENERATED_KEYS);
    assertTrue(basicKey.equals(simplifiedKey));
    assertTrue(simplifiedKey.equals(basicKey));
}
 
源代码10 项目: coming   文件: 1205753_EmbedPooledConnection_0_t.java
void resetRealConnection() throws SQLException {

		// ensure any outstanding changes from the previous
		// user are rolledback.
		realConnection.rollback();

		// clear any warnings that are left over
		realConnection.clearWarnings();

		// need to reset transaction isolation, autocommit, readonly, holdability states
		if (realConnection.getTransactionIsolation() != defaultIsolationLevel) {

			realConnection.setTransactionIsolation(defaultIsolationLevel);
		}

		if (!realConnection.getAutoCommit())
			realConnection.setAutoCommit(true);

		if (realConnection.isReadOnly() != defaultReadOnly)
			realConnection.setReadOnly(defaultReadOnly);

		if (realConnection.getHoldability() != ResultSet.HOLD_CURSORS_OVER_COMMIT)
			realConnection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);

		// reset any remaining state of the connection
		realConnection.resetFromPool();
		if (SanityManager.DEBUG)
		{
			SanityManager.ASSERT(realConnection.transactionIsIdle(),
			"real connection should have been idle at this point"); 			
		}
	}
 
源代码11 项目: coming   文件: 1205753_EmbedPooledConnection_0_s.java
void resetRealConnection() throws SQLException {

		// ensure any outstanding changes from the previous
		// user are rolledback.
		realConnection.rollback();

		// clear any warnings that are left over
		realConnection.clearWarnings();

		// need to reset transaction isolation, autocommit, readonly, holdability states
		if (realConnection.getTransactionIsolation() != defaultIsolationLevel) {

			realConnection.setTransactionIsolation(defaultIsolationLevel);
		}

		if (!realConnection.getAutoCommit())
			realConnection.setAutoCommit(true);

		if (realConnection.isReadOnly() != defaultReadOnly)
			realConnection.setReadOnly(defaultReadOnly);

		if (realConnection.getHoldability() != ResultSet.HOLD_CURSORS_OVER_COMMIT)
			realConnection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);

		// reset any remaining state of the connection
		realConnection.resetFromPool();
		if (SanityManager.DEBUG)
		{
			SanityManager.ASSERT(realConnection.transactionIsIdle(),
			"real connection should have been idle at this point"); 			
		}
	}
 
源代码12 项目: gemfirexd-oss   文件: ClientDBMetaData.java
/**
 * {@inheritDoc}
 */
@Override
public int getResultSetHoldability() throws SQLException {
  this.conn.lock();
  try {
    initServiceMetaData();
    return this.serviceMetaData
        .isDefaultResultSetHoldabilityHoldCursorsOverCommit() ? ResultSet.HOLD_CURSORS_OVER_COMMIT
        : ResultSet.CLOSE_CURSORS_AT_COMMIT;
  } finally {
    this.conn.unlock();
  }
}
 
源代码13 项目: gemfirexd-oss   文件: EmbedXAConnection.java
/**
	Are held cursors allowed. If the connection is attached to
       a global transaction then downgrade the result set holdabilty
       to CLOSE_CURSORS_AT_COMMIT if downgrade is true, otherwise
       throw an exception.
       If the connection is in a local transaction then the
       passed in holdabilty is returned.
*/
public int  checkHoldCursors(int holdability, boolean downgrade)
       throws SQLException
   {
	if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) {		
		if (isGlobal()) {
               if (!downgrade)
                   throw Util.generateCsSQLException(SQLState.CANNOT_HOLD_CURSOR_XA);
               
               holdability = ResultSet.CLOSE_CURSORS_AT_COMMIT;
           }
	}

	return super.checkHoldCursors(holdability, downgrade);
}
 
源代码14 项目: sharding-jdbc-1.5.1   文件: ShardingStatement.java
public ShardingStatement(final ShardingConnection shardingConnection) {
    this(shardingConnection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
 
源代码15 项目: sharding-jdbc-1.5.1   文件: ShardingStatement.java
public ShardingStatement(final ShardingConnection shardingConnection, final int resultSetType, final int resultSetConcurrency) {
    this(shardingConnection, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
 
public ShardingPreparedStatement(final ShardingConnection shardingConnection, final String sql) {
    this(shardingConnection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
 
源代码17 项目: presto   文件: PrestoDatabaseMetaData.java
@Override
public int getResultSetHoldability()
        throws SQLException
{
    return ResultSet.HOLD_CURSORS_OVER_COMMIT;
}
 
CassandraStatement(CassandraConnection con, String cql) throws SQLException
{
    this(con, cql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
 
源代码19 项目: shardingsphere   文件: ShardingSphereStatement.java
public ShardingSphereStatement(final ShardingSphereConnection connection) {
    this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
 
源代码20 项目: jdbc-driver-csv   文件: CsvConnection.java
@Override
public int getHoldability() throws SQLException {
    checkOpen();

    return ResultSet.HOLD_CURSORS_OVER_COMMIT;
}