Search code examples
javapostgresqldnsglassfishconnection-pool

How to set Glassfish connection pool using DNS in ServerName and Url


My database is intalled on server behind a rooter that has a dynamic IP, i use a kind of DynDns to update DNS-DB-Server with the last Public IP of the server

in Glassfish connection pool properties i have entred as server name the DNS-DB-Server and in the URL jdbc:postgresql://DNS-DB-Server:5432...

all works fine till the public IP changes ofcourse my DNS-DB-Server points to the new Public IP but my web-application that uses the connection-pool can't reach the Database

is there some think else to configure in Glassfish to refresh the connection-pool.


Solution

  • I'm not sure if the IP would be refreshed, but you certainly need to refresh the open connections. Configure connection validation on your connection pool, and in this case you probably want to set that all connections are refreshed when a validation fails. More info e.g. here (in the Connection validation section)