예제 #1
0
  /**
   * Rollback the current local transaction
   *
   * @param startTxn
   * @throws SQLException
   */
  public void rollback(boolean startTxn) throws SQLException {

    // Check to see the connection is open
    checkConnection();
    if (!autoCommitFlag) {
      try {
        if (this.inLocalTxn) {
          this.inLocalTxn = false;
          try {
            ResultsFuture<?> future = this.dqp.rollback();
            future.get();
          } catch (Exception e) {
            throw TeiidSQLException.create(e);
          }
          logger.fine(JDBCPlugin.Util.getString("MMConnection.Rollback_success")); // $NON-NLS-1$
        }
      } finally {
        if (startTxn) {
          this.inLocalTxn = false;
        } else {
          this.autoCommitFlag = true;
        }
      }
    }
  }
예제 #2
0
  String getVDBName() throws SQLException {
    // Check to see the connection is open
    checkConnection();
    // get the virtual database name to which we are connected.

    return this.serverConn.getLogonResult().getVdbName();
  }
예제 #3
0
 protected void forgetTransaction(XidImpl arg0) throws SQLException {
   checkConnection();
   try {
     ResultsFuture<?> future = this.dqp.forget(arg0);
     future.get();
   } catch (Exception e) {
     throw TeiidSQLException.create(e);
   }
 }
예제 #4
0
  public DatabaseMetaDataImpl getMetaData() throws SQLException {
    // Check to see the connection is open
    checkConnection();

    if (dbmm == null) {
      dbmm = new DatabaseMetaDataImpl(this);
    }
    return dbmm;
  }
예제 #5
0
 protected Xid[] recoverTransaction(int arg0) throws SQLException {
   checkConnection();
   try {
     ResultsFuture<Xid[]> future = this.dqp.recover(arg0);
     return future.get();
   } catch (Exception e) {
     throw TeiidSQLException.create(e);
   }
 }
예제 #6
0
 /**
  * This method makes any changes involved in a transaction permanent and releases any locks held
  * by the connection object. This is only used when auto-commit is set to false.
  *
  * @throws SQLException if the transaction had been rolled back or marked to roll back.
  */
 public void commit() throws SQLException {
   checkConnection();
   if (!autoCommitFlag) {
     try {
       directCommit();
     } finally {
       inLocalTxn = false;
     }
   }
 }
예제 #7
0
 protected int prepareTransaction(XidImpl arg0) throws SQLException {
   checkConnection();
   transactionXid = null;
   try {
     ResultsFuture<Integer> future = this.dqp.prepare(arg0);
     return future.get();
   } catch (Exception e) {
     throw TeiidSQLException.create(e);
   }
 }
예제 #8
0
 protected void endTransaction(XidImpl arg0, int arg1) throws SQLException {
   checkConnection();
   this.autoCommitFlag = true;
   try {
     ResultsFuture<?> future = this.dqp.end(arg0, arg1);
     future.get();
   } catch (Exception e) {
     throw TeiidSQLException.create(e);
   }
 }
예제 #9
0
 protected void rollbackTransaction(XidImpl arg0) throws SQLException {
   checkConnection();
   transactionXid = null;
   this.autoCommitFlag = true;
   try {
     ResultsFuture<?> future = this.dqp.rollback(arg0);
     future.get();
   } catch (Exception e) {
     throw TeiidSQLException.create(e);
   }
 }
예제 #10
0
 protected void startTransaction(XidImpl arg0, int arg1, int timeout) throws SQLException {
   checkConnection();
   try {
     ResultsFuture<?> future = this.dqp.start(arg0, arg1, timeout);
     future.get();
   } catch (Exception e) {
     throw TeiidSQLException.create(e);
   }
   transactionXid = arg0;
   this.autoCommitFlag = false;
 }
예제 #11
0
  public StatementImpl createStatement(
      int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
    // Check to see the connection is open
    checkConnection();

    validateResultSetType(resultSetType);
    validateResultSetConcurrency(resultSetConcurrency);
    // TODO: implement close cursors at commit

    // add the statement object to the map
    StatementImpl newStatement = new StatementImpl(this, resultSetType, resultSetConcurrency);
    addStatement(newStatement);

    return newStatement;
  }
예제 #12
0
  public void setAutoCommit(boolean autoCommit) throws SQLException {
    // Check to see the connection is open
    checkConnection();

    if (autoCommit == this.autoCommitFlag) {
      return;
    }

    this.autoCommitFlag = autoCommit;

    if (autoCommit) {
      directCommit();
    } else {
      inLocalTxn = false;
    }
  }
예제 #13
0
  public CallableStatementImpl prepareCall(
      String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
      throws SQLException {
    // Check to see the connection is open
    checkConnection();

    validateResultSetType(resultSetType);
    validateResultSetConcurrency(resultSetConcurrency);
    validateSQL(sql);
    // TODO: implement close cursors at commit

    // add the statement object to the map
    CallableStatementImpl newStatement =
        new CallableStatementImpl(this, sql, resultSetType, resultSetConcurrency);
    addStatement(newStatement);
    return newStatement;
  }
예제 #14
0
  public ResultsFuture<?> submitSetAutoCommitTrue(boolean commit) throws SQLException {
    // Check to see the connection is open
    checkConnection();

    if (this.autoCommitFlag) {
      return ResultsFuture.NULL_FUTURE;
    }

    this.autoCommitFlag = true;

    try {
      if (commit) {
        return dqp.commit();
      }
      return dqp.rollback();
    } catch (XATransactionException e) {
      throw TeiidSQLException.create(e);
    }
  }
예제 #15
0
  public PreparedStatementImpl prepareStatement(
      String sql,
      int resultSetType,
      int resultSetConcurrency,
      int resultSetHoldability,
      int autoGeneratedKeys)
      throws SQLException {
    // Check to see the connection is open
    checkConnection();

    validateResultSetType(resultSetType);
    validateResultSetConcurrency(resultSetConcurrency);
    validateSQL(sql);

    // add the statement object to the map
    PreparedStatementImpl newStatement =
        new PreparedStatementImpl(this, sql, resultSetType, resultSetConcurrency);
    newStatement.setAutoGeneratedKeys(autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS);
    addStatement(newStatement);
    return newStatement;
  }
예제 #16
0
 public boolean getAutoCommit() throws SQLException {
   // Check to see the connection is open
   checkConnection();
   return autoCommitFlag;
 }
예제 #17
0
 public String getCatalog() throws SQLException {
   // Check to see the connection is open
   checkConnection();
   // catalogs are not supported
   return this.serverConn.getLogonResult().getVdbName();
 }
예제 #18
0
 /**
  * This method gets the ServerConnection object wrapped by this object.
  *
  * @return ServerConnection object
  */
 public ServerConnection getServerConnection() throws SQLException {
   // Check to see the connection is open
   checkConnection();
   return serverConn;
 }
예제 #19
0
 public int getVDBVersion() throws SQLException {
   checkConnection();
   return this.serverConn.getLogonResult().getVdbVersion();
 }
예제 #20
0
  /**
   * Get's the name of the user who got this connection.
   *
   * @return Sring object giving the user name
   * @throws SQLException if the connection is closed
   */
  String getUserName() throws SQLException {
    checkConnection();

    return this.serverConn.getLogonResult().getUserName();
  }
예제 #21
0
 /**
  * This method will return the first warning reported by calls on this connection, or null if none
  * exist.
  *
  * @return A SQLWarning object if there are any warnings.
  * @throws SQLException, should never occur
  */
 public SQLWarning getWarnings() throws SQLException {
   // Check to see the connection is open
   checkConnection();
   return null; // we don't have any warnings
 }