在进行数据库操作的时候怎么才能在超时后终止操作???

seagullgao 2004-12-22 09:46:45
我使用JDBC进行数据库操作,想在执行事务的时候加入超时的特性,可是不知道怎么来实现???
(不能使用JTA,应为只是一个单纯的java class,没有应用服务器的支持!)
...全文
83 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zealVampire 2004-12-25
  • 打赏
  • 举报
回复
数据库连接也是socket连接 socket连接肯定有超时的机制的吧
Statement 等也应当有
jFresH_MaN 2004-12-22
  • 打赏
  • 举报
回复
设置事务的超时时间不就可以了?
treeroot 2004-12-22
  • 打赏
  • 举报
回复
设置事物的超时时间不就可以了?
xueqs 2004-12-22
  • 打赏
  • 举报
回复
gz
treeroot 2004-12-22
  • 打赏
  • 举报
回复
试一下Statement.setTimeout(int s);

/**
* Sets the number of seconds the driver will wait for a
* <code>Statement</code> object to execute to the given number of seconds.
* If the limit is exceeded, an <code>SQLException</code> is thrown.
*
* @param seconds the new query timeout limit in seconds; zero means
* there is no limit
* @exception SQLException if a database access error occurs
* or the condition seconds >= 0 is not satisfied
* @see #getQueryTimeout
*/
void setQueryTimeout(int seconds) throws SQLException;
seagullgao 2004-12-22
  • 打赏
  • 举报
回复
怎么设置啊?注意我没有应用服务器(如weblogic)的支持啊,只是单纯的java class,所以没有办法使用JTA的啊!

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧