pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: Frankqsy (@Frankqsy) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #879: loginTimeout in java.sql.DriverManager never be used
Date: Sun, 23 Jul 2017 14:03:56 +0000
Message-ID: <[email protected]> (raw)
in the file:pgjdbc/src/main/java/org/postgresql/PGProperty.java,line 246.
```
LOGIN_TIMEOUT("loginTimeout", "0",
"Specify how long to wait for establishment of a database connection.");
```
the default value "0" will lead to the result that the value set in DriverManager never be used.because the code using the value as follows:
in the file:pgjdbc/pgjdbc/src/main/java/org/postgresql/Driver.java,line 633
```
private static long timeout(Properties props) {
String timeout = PGProperty.LOGIN_TIMEOUT.get(props);
if (timeout != null) {
try {
return (long) (Float.parseFloat(timeout) * 1000);
} catch (NumberFormatException e) {
LOGGER.log(Level.WARNING, "Couldn't parse loginTimeout value: {0}", timeout);
}
}
return (long) DriverManager.getLoginTimeout() * 1000;
}
```
and in the method "get" of PGProperty,the code as follows:
in the file:pgjdbc/src/main/java/org/postgresql/PGProperty.java,line 475.
```
public String get(Properties properties) {
return properties.getProperty(_name, _defaultValue);
}
```
as above,the LOGIN_TIMEOUT will always get the default value of "0",the loginTimeout value set in the DriverManager will never be used.
if we want to set the loginTimeout, we must put it into properties,this will make confusion when we develop.
The phenomenon will be that the login will hang if the network is error although we have set the loginTimeout value in the DriverManager.
view thread (14+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] issue #879: loginTimeout in java.sql.DriverManager never be used
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox