简体   繁体   中英

How to find out the set login timeout for a Connection object in Java?

I have a Connection object in Java(1.5) and I want to know what value was set for the login timeout. Is there a way to access this?

I am trying to set the timeout in the URL itself, like jdbc:server//host....etc..;loginTimeout=5 and I am basically trying to confirm that it has taken effect

Use DriverManager class to set up database server login connection timeout.

// Getting timeout value
int timeout = DriverManager.getLoginTimeout();

// Setting timeout value
DriverManager.setLoginTimeout(timeout)

获取DriverManager的LoginTimeout的唯一方法是直接从DriverManager使用:

int timeout = DriverManager.getLoginTimeout();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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