简体   繁体   English

sybase和jdbc。 无法提交jdbc事务。 读超时

[英]sybase and jdbc. Could not commit jdbc transaction. Read time out

After my app tries committing many transactions after several mins, I'm getting the following exception: 在我的应用尝试在几分钟后提交许多事务后,出现以下异常:

could not commit jdbc transaction nested exception is java.sql.sqlexception: jz006: caught ioexception: java.net.SocketTimeoutException: Read timed out..." 无法提交jdbc事务嵌套的异常是java.sql.sqlexception:jz006:捕获的ioexception:java.net.SocketTimeoutException:读取超时...”

I'm using Sybase with the JDBC 4 driver with Spring JDBC, and I found this link: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc39001.0707/html/prjdbc0707/prjdbc070714.htm Could I just use any of the following: 我将Sybase和JDBC 4驱动程序与Spring JDBC一起使用,并且找到了以下链接: http : //infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc39001.0707/html /prjdbc0707/prjdbc070714.htm我可以使用以下任何一种方法:

SESSION_TIMEOUT 会话超时
DEFAULT_QUERY_ TIMEOUT DEFAULT_QUERY_ TIMEOUT
INTERNAL_QUERY_TIMEOUT INTERNAL_QUERY_TIMEOUT

One idea is to make the transactions in batch, but I have no time to develop that. 一种想法是批量进行事务处理,但是我没有时间进行开发。 What options are there to avoid getting that error? 有什么选择可以避免发生该错误?

Check if your processes are blocking each other when they execute (or ask your DBA if you're not sure how to check). 检查您的进程在执行时是否相互阻塞(如果不确定如何检查,请询问您的DBA)。 Depending upon the connection properties (specifically autocommit being set to off) you may not actually be committing each transaction fully before the next one is attempted and they may block each other if you're using a connection pool with multiple threads. 根据连接属性(特别是将自动提交设置为关闭),在尝试进行下一个事务之前,您可能实际上未完全提交每个事务;如果您正在使用具有多个线程的连接池,则它们可能会相互阻塞。 Talk to your DBA and check the table's locking scheme as for example if its set to allpages locking, you will hold locks at the page rather than row-level of data. 与您的DBA交谈并检查表的锁定方案,例如,如果表的锁定方案设置为allpages锁定,您将在页面而不是行级数据上保持锁定。 You can also check this yourself via sp_help . 您也可以自己通过sp_help进行检查。 Some more info regarding the various types of locking scheme can be found at http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc20021_1251/html/locking/X25549.htm (old version but still valid on current versions). 有关各种类型的锁定方案的更多信息,请参见http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc20021_1251/html/locking/X25549.htm (旧版本,在当前版本上仍然有效)。

You can check for locks via sp_who, sp_lock or against the system tables directly (select spid, blocked from master..sysprocesses where blocked !=0 is a very simple one to get the process and blocking process you can add more columns to this as required). 您可以通过sp_who,sp_lock或直接针对系统表检查锁定(选择spid,从master..sysprocesses进行阻止,其中blocked!= 0是获取过程和阻止过程的非常简单的方法,您可以向其添加更多列需要)。

You should also ask your DBA to check that the transactions are optimal as for example a tablescan on an update could well lock out the whole table to other transactions and would lead to the timeout issues you're seeing here. 您还应该要求DBA检查事务是否是最佳的,例如,对更新进行表扫描很可能将整个表锁定在其他事务上,并会导致您在此处看到超时问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM