-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]loginTimeout in URL not valid if DriverManager.setLoginTimeout #1048
Comments
I can confirm this is a valid issue in the driver, and the Login Timeout property value must not be overridden if it does not exceed global Max Timeout value (returned by I've created PR #1049 to fix the issue, please take a look and let me know if works well for you. |
Hi @cheenamalhotra Do you think if we can use DriverManger.getLoginTimeout() when there is no LoginTimeout property? Thanks |
According to Java Specs, There is no alternative or "setMaxLoginTimeout()" API available in DriverManager, and hence the driver must respect Java specifications. About the default value of this property, as mentioned in Microsoft Docs, the default value for this connection property is 15 seconds and will not change. |
Hi @cheenamalhotra The current fix is fine to me for I won't set LoginTimeout larger than DriverManager.setLoginTimeout. But I'm worried that others may be confusing that why loginTimeout in URL is not valid if it's larger than a specific value when they forget they've set the DriverManager.setLoginTimeout somewhere. |
I verified the behavior with other JDBC drivers and seems like the I fixed my PR accordingly, please take a look. Thanks! |
Driver version
6.2.2
SQL Server version
Any
Client Operating System
Linux or Mac or Windows
JAVA/JVM version
1.8
Table schema
No need
Problem description
When I set logintimeout in URL, I expect that the connection would timeout by the setting in URL. But it would timeout by the global loginTimeout setting.
And the problem is caused by the loginTimeout property is overwritten in SQLServerDriver.parseAndMergeProperties

Reproduction code
With the following code, the connection would timeout in 60 seconds not 5 seconds.
DriverManager.setLoginTimeout(60)
println(new Date().toString())
try {
url = "jdbc:sqlserver://10.0.2.15;userName=sa;password=PASSW0RD;database=master;socketTimeout=10000;logintimeout=5"
def sql = Sql.newInstance(url, "system", "123456", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
}
catch (Exception e) {
println(e.getMessage())
println(new Date().toString())
}
The text was updated successfully, but these errors were encountered: