我对jsp不熟悉,我的理解这段程序
try
{
锁表
}
catch(Exception ex)
{
rollback(); //锁已经解了
}
finally
{
if 连接存在
设置自动提交
断连 ////锁也应该解了
}这段代码加锁,很快又解了
try
{
锁表
}
catch(Exception ex)
{
rollback(); //锁已经解了
}
finally
{
if 连接存在
设置自动提交
断连 ////锁也应该解了
}这段代码加锁,很快又解了
解决方案 »
- 关于Oracle奇怪的表的问题
- --悲哀:按书上写了个存储过程,不知道咋调用--
- Oracle初始配置及导入问题
- start with ... connect by 层次查询的用法报错:ORA-01436: CONNECT BY loop in user data
- Oracle多表关联查询问题!解决立即给分
- snowy_howe ,运行规律老问题
- 关于oracle的用户,表空间和表空间中的内容
- rownum到底有什么用的,要用时不好用
- 数据库中有一表,估计数据量很大(几千万),想问一下,用自增字段合适吗?
- 高手们过来拿分呀。。。。
- 奇怪的问题,关于跨用户更新数据
- 能否用Sql语句实现这样的功能??
try
{
锁表
}
catch(Exception ex)//如果try{}程序出错执行这里
{
rollback(); //锁已经解了
}
finally//try{}程序段执行后执行这里
{
if 连接存在
设置自动提交
断连 ////锁也应该解了
}断连后锁解了吗?
我把
if(conn!=null)
{
conn.setAutoCommit(true);
pstat.close();
conn.close();
}
这段程序去掉也不好用啊!
谢谢!
我同时打开两个sqlplus窗口,在一个中
lock table project in exclusive mode
在另一个中update就不行,
着证明语句好用啊!
try
{
conn = pox.getConnection();
conn.setAutoCommit(false);
pstat = conn.prepareStatement("lock table project in exclusive mode");
pstat.executeUpdate();
//conn.commit();
}
在SQLPLUS窗口,执行加锁,看看锁加上没有还有pstat.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 吧!
lock table是定义语言吗?
我记得好象是DML
不好意思我对数据库了解不多!
maohaisheng
我找到错误了,我在在SQLPLUS窗口里执行加锁后不管是什么程序都访问不了表了
看来是我的程序没有加上锁!
一定是我jsp代码的错误!
我在查查java方面的资料看!
等我解决了问题后把解决的方法写到这里后就给你结帖!
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();
就好了!
不好意思!
结帖了!