1

I have a Spring MVC webapp running on Tomcat container. The datasource configuration is like the following, in context.xml

<Resource   factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            name="jdbc/myDataSource"
            type="javax.sql.DataSource"
            .....
            url="jdbc:postgresql://myDatabase:xxxx/dbname" />

myDatabase is a name resolved by DNS, it's not the ip address.

Now, suppose that there is a change on DNS side so myDatabase points to a new ip address, is this change transparent to Tomcat, or I need to restart it? In this last case, there is any automation that can be implemented in order to automatically update the connection?

Thanks!

rocky
  • 76
  • 1
  • 7

1 Answers1

0

It will be automatically resolved to new IP address on next DB connection. Old connections will still point to old server.

Details(based on comment) - Its pretty much a standard DNS resolution process, So whenever a new connection is requested, the hostname given will get resolved to an IP address by the OS and at that point JDBC will connect to the returned IP address.

mdeora
  • 4,152
  • 2
  • 19
  • 29
  • I am just curious. Is this documented? or experience? – JoSSte Oct 24 '18 at 11:25
  • Its pretty much a standard DNS resolution process, So whenever a new connection is requested, the hostname given will get resolved to an IP address by the OS and at that point JDBC will connect to the returned IP address. – mdeora Oct 24 '18 at 11:30
  • Ah! Of course. maybe you could update you answer with those details? ;-) – JoSSte Oct 24 '18 at 11:54