select b.owner,b.object_name,a.session_id,a.locked_mode
from v$locked_object a,dba_objects b
where b.object_id = a.object_id;
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid order by b.logon_time;
2023-02-27 16:56:37
alter system kill session '29,14735';
SELECT lpad(' ',decode(l.xidusn ,0,3,0))||l.oracle_username User_name,
o.owner,o.object_name,o.object_type,s.sid,s.serial#
FROM v$locked_object l,dba_objects o,v$session s
WHERE l.object_id=o.object_id
AND l.session_id=s.sid
ORDER BY o.object_id,xidusn DESC
java代码中前一段代码使用mybatis得代码,后一段代码使用类似hibernate得写法,对同一个table和同一行(同一条)数据进行修改(进行update),估计前一个update没有提交,后一个update看到没提交一直锁表。
代码卡在那里。
修改把前一段代码得update代码里加上强制commit代码
try {标签:java,锁表,代码,object,session,oracle,locked,id,transactionManager From: https://www.cnblogs.com/bhliuyou/p/17163333.html
DataSourceTransactionManager transactionManager = (DataSourceTransactionManager)BeanContextUtil.getApplicationContext().getBean("transactionManager");
DefaultTransactionDefinition defr = new DefaultTransactionDefinition();
defr.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus status = transactionManager.getTransaction(defr);
//更新逻辑代码TODO
transactionManager.commit(status);
return num;
}catch (Exception e){
e.printStackTrace();
//return -1;
log.error("error updateCancelForCredit",e);
}