Oracle SQL与java。更新数据库语句

时间:2015-11-19 10:38:27

标签: java sql oracle

public boolean executeUpdate() throws SQLException {
        String updateString= "UPDATE CLIENTE SET ID_PLANO= ? WHERE ID_CLIENTE= ? ;";
        PreparedStatement statment = null;
        int result=0;
        try {
            v_conn.setAutoCommit(false);
            statment = v_conn.prepareStatement(updateString);
            statment.setInt(1, 1);
            statment.setInt(2, 1);
            result=statment.executeUpdate();
            v_conn.commit();
        } catch (SQLException e) {
            System.out.println(e.getMessage());
            if (v_conn != null) {
                try {
                    System.err.print("Transaction is being rolled back");
                    v_conn.rollback();
                } catch (SQLException excep) {
                    System.out.println(excep.getMessage());
                }
            }
        } finally {
            if (statment != null) {
                statment.close();
            }
            v_conn.setAutoCommit(true);
        }
        if (result == 1) {
            return true;
        } else {
            return false;
        }
    }

这段代码无法更新我的数据库,你知道为什么吗? 语句脚本在SQL中运行完美。 你能帮助我吗?

我在这里度过的时间吓坏了。

0 个答案:

没有答案