[英]How to set jdbc connection lifetime and timeout?
I want to set jdbc connection lifetime and lifespan how do i do it. 我想设置jdbc连接的寿命和寿命,我该怎么做。
I tried using properties. 我尝试使用属性。
Properties info = new properties();
info.put(user,"username");
info.put(password,"password");
info.put(connection lifetime, 0);
DriverManager.getConnection(server,info)
But this didn't work please help. 但这没有用,请帮忙。
Try this: 尝试这个:
info.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT, "2000");
Reference: Setting Network Timeout for JDBC connection 参考: 为JDBC连接设置网络超时
Note that not all JDBC JARs support setting a timeout this way. 请注意,并非所有的JDBC JAR都支持以这种方式设置超时。 Sometimes you have to do it programatically.
有时,您必须以编程方式执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.