Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

DriverManager.setLoginTimeout(10) not work as expected.

Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have set the DriverManager.setLoginTimeout(10), I expect if the connection cannot success within 10 seconds, it will give up and return a null conn, but the actual result is it wait for about 2 minutes 30 seconds and then return exception, why?
how to make the connection just try for 10 seconds, and if still cannot connect success within 10 seconds, then give up and return null connection?

the error log is

16:01:19,521 INFO  [com.frw.database.DatabaseConnectionFactory] (default task-49) ComConfig.CHUBB_URL:jdbc:sqlserver://xx.xx.xx.xx:1464; DatabaseName=Director
16:01:19,521 INFO  [com.frw.database.DatabaseConnectionFactory] (default task-49) ComConfig.CHUBB_QUERY_USER:DirectorQueryUser
16:03:49,603 ERROR [com.frw.database.DatabaseConnectionFactory] (default task-49) createChubbQueryConnection: The TCP/IP connection to the host xx.xx.xx.xx, port 1464 has failed. Error: "Connection timed out: no further information.. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

    Bookmark Topic Watch Topic
  • New Topic