数据库连接池, 怎么设置一个连接查询超时时间.
情况是这样的.查询oracle数据库,经常会出现锁死.如下
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at oracle.net.ns.Packet.receive(Packet.java:240)
at oracle.net.ns.DataPacket.receive(DataPacket.java:92)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:172)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:117)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:92)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:77)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1034)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1010)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:588)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:183)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:780)
at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:855)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1178)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1770)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1739)
- locked <0x000000075f721b40> (a oracle.jdbc.driver.T4CConnection)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:299)
at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.logicalcobwebs.proxool.ProxyStatement.invoke(ProxyStatement.java:68)
at org.logicalcobwebs.cglib.proxy.Proxy$ProxyImpl$$EnhancerByCGLIB$$47d2977f.execute(<generated>)
at cn.ffcs.dataMemcached.dao.CommonDao.queryGroupTerminalInfo(CommonDao.java:223)
at cn.ffcs.dataMemcached.service.CommonService.partMemberSsoTableSyn(CommonService.java:169)
at cn.ffcs.dataMemcached.task.PartMemberSsoJob.execute(PartMemberSsoJob.java:23)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
这个查询一直卡在这边, 如何设置超时呢.
目前采用proxool,如果不行,也可以采用C3P0,但是我查阅了一下他们的设置参数好像都没有看到有如此的设置.在JDBC查询的时候倒是可以设置timeOut.但是好像没有效果.
--------------------编程问答-------------------- 很久没来CSDN了. 不知道求助效果怎么样 --------------------编程问答-------------------- http://www.wujianrong.com/archives/2007/08/c3p0.html
c3p0, 说的挺详细的。 --------------------编程问答--------------------
没有我所说的设置哦 --------------------编程问答-------------------- 在数据源的配置上设置
<Context>
<Resource
name="jndi/mydb" //资源的jndi名字
type="javax.sql.DataSource" //资源类型
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://localhost:1433;databasename=mydb"
username="sa"
password="sa"
maxActive="10" //连接池中活动的连接数的最大数量
maxIdle="5" //最大的空闲连接数的数量
maxWait="5000" //响应的最大时间,超时失效
/>
</Context>
--------------------编程问答--------------------
你这个超时之后是以什么形式退出呢, 是以异常的方式么.? --------------------编程问答-------------------- 这个我搞错了 不是你要求的超时设置 --------------------编程问答-------------------- 你可以写一个线程,监控.如果超时就释放当前session
补充:Java , Java EE