示例#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
 }