在java里面执行一条oracle的sql更新语句,没有在任何事务里面,有没有被意外回退的可能?包括数据库执行的一些回退操作会不会引起这个更新操作回退。
希望老鸟们前来回答,分多,人傻,速来!
另外恭祝大伙元宵节快乐!人多分再加

解决方案 »

  1.   

    不会,除非你的sql写错了。执行出错
      

  2.   

    只要你 pstmt.execute(sql); 类似这样的jdbc语句执行了,那么就写入了数据库,不可能回退。
      

  3.   

    只要执行成功了不可能被rollback
      

  4.   


    public T execute(StatementCallback<T> action) throws DataAccessException {
    Assert.notNull(action, "Callback object must not be null");
    Connection con = DataSourceUtils.getConnection(getDataSource());
    Statement stmt = null;
    try {
    Connection conToUse = con;
    if (this.nativeJdbcExtractor != null &&
    this.nativeJdbcExtractor.isNativeConnectionNecessaryForNativeStatements()) {
    conToUse = this.nativeJdbcExtractor.getNativeConnection(con);
    }
    stmt = conToUse.createStatement();
    applyStatementSettings(stmt);
    Statement stmtToUse = stmt;
    if (this.nativeJdbcExtractor != null) {
    stmtToUse = this.nativeJdbcExtractor.getNativeStatement(stmt);
    }
    T result = action.doInStatement(stmtToUse);
    handleWarnings(stmt);
    return result;
    }
    catch (SQLException ex) {
    // Release Connection early, to avoid potential connection pool deadlock
    // in the case when the exception translator hasn't been initialized yet.
    JdbcUtils.closeStatement(stmt);
    stmt = null;
    DataSourceUtils.releaseConnection(con, getDataSource());
    con = null;
    throw getExceptionTranslator().translate("StatementCallback", getSql(action), ex);
    }
    finally {
    JdbcUtils.closeStatement(stmt);
    DataSourceUtils.releaseConnection(con, getDataSource());
    }
    }这个是update时候调用的execute,没有回退吧
      

  5.   

    对于Oracle的操作,是通过不同的用户操作来执行是否回滚和提交的,一般使用jdbc操作的话,除非你手动的回滚,否则不会回滚的。如果你在数据库里面也同时操作,就有一个commit的先后顺序,数据库里的操作,就是在sqlplus里面操作是必须要手动commit的,否则就不会更新,虽然你在这个sqlplus里面查询没有提交但是结果已经更改了,但你换个sqlplus就会发现还是原来的。主要你要对Oracle理解就明白了!