读书人

Connection并发有关问题

发布时间: 2012-09-29 10:30:01 作者: rapoo

Connection并发问题

Connection lock = getConnection();lock.setAutoCommit(false);lock.createStatement().execute("select * from zhaojianyong for update");final Connection connection = getConnection();connection.setAutoCommit(false);new Thread(){    @Override    public void run() {        try {            Thread.sleep(10 * 1000);        } catch (InterruptedException ex) {            ex.printStackTrace();        }        try {            System.out.println("begin commit");            connection.commit();            System.out.println("end commit");        } catch (SQLException ex) {            ex.printStackTrace();        }    }}.start();connection.createStatement().execute("update zhaojianyong set id= 8 where id != 0");

以上的程序会怎么运行呢???

Connection的并发问题,我感觉JDBC规范里说得很模糊。
不知道如果一个连接正在更新,在另一个线程中close commit rollback会怎么样。

有没有牛人能解答。。。

读书人网 >其他数据库

热点推荐