首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Connection并发有关问题

2012-09-29 
Connection并发问题Connection lock getConnection()lock.setAutoCommit(false)lock.createStatement(

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会怎么样。

有没有牛人能解答。。。

热点排行