我对jsp不熟悉,我的理解这段程序
try 
{
锁表
}
catch(Exception ex)
{
rollback();  //锁已经解了
}
finally
{
  if 连接存在
   设置自动提交
   断连 ////锁也应该解了
}这段代码加锁,很快又解了

解决方案 »

  1.   

    谢谢,我解释一下!
    try 
    {
    锁表
    }
    catch(Exception ex)//如果try{}程序出错执行这里
    {
    rollback();  //锁已经解了
    }
    finally//try{}程序段执行后执行这里
    {
      if 连接存在
       设置自动提交
       断连 ////锁也应该解了
    }断连后锁解了吗?
    我把
    if(conn!=null)
    {
    conn.setAutoCommit(true);
    pstat.close();
    conn.close();
    }
    这段程序去掉也不好用啊!
    谢谢!
      

  2.   

    补充:
    我同时打开两个sqlplus窗口,在一个中
    lock table project in exclusive mode
    在另一个中update就不行,
    着证明语句好用啊!
      

  3.   

    这样吧,你把异常处理的也去了,只执行
    try
    {
    conn = pox.getConnection();
    conn.setAutoCommit(false);
    pstat = conn.prepareStatement("lock table project in exclusive mode");
    pstat.executeUpdate();
    //conn.commit();
    }
    在SQLPLUS窗口,执行加锁,看看锁加上没有还有pstat.executeUpdate();这个函数应该有返回值吧,查查返回值有什么具体信息
      

  4.   

    public int executeUpdate()
                      throws SQLExceptionExecutes 
    the SQL INSERT, UPDATE or DELETE statement in this PreparedStatement object. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.Returns:
    either the row count for INSERT, UPDATE or DELETE statements; or 0 for SQL statements that return nothingThrows:
    SQLException - if a database access error occurs好象没有lock table啊,不会只能执行INSERT, UPDATE or DELETE 吧!
      

  5.   

    在SQLPLUS窗口,执行加锁,是好用的!
      

  6.   

    such as SQL DDL statements, can be executed----应该可以加锁吧你判断以下的它的返回值是不是0
      

  7.   

    是0
    lock table是定义语言吗?
    我记得好象是DML
    不好意思我对数据库了解不多!
      

  8.   

    谢谢您
    maohaisheng
    我找到错误了,我在在SQLPLUS窗口里执行加锁后不管是什么程序都访问不了表了
    看来是我的程序没有加上锁!
    一定是我jsp代码的错误!
    我在查查java方面的资料看!
    等我解决了问题后把解决的方法写到这里后就给你结帖!
      

  9.   

    public boolean execute()
                    throws SQLException
    Executes any kind of SQL statement. Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by the methods executeQuery and executeUpdate.Throws:
    SQLException - if a database access error occursSee Also: 
    Statement.execute(java.lang.String)刚刚查了java的api:
    跟上面的public int executeUpdate()比一比;
    Executes any kind of SQL statement
    呵呵,刚才我粗心啊!
    把pstat.executeUpdate();
    改为pstat.execute();
    就好了!
    不好意思!
    结帖了!