0

I have a background thread in my web application. So let's assume I have somewhere in my code BackgroundThread.getInstance().start() which starts only once BackgroundThread.

BackgroundThread uses Drivermanager.getconnection to get a connection, do something, close the connection and than wait 10 seconds. Then in the infinite loop it repeats the process.

But if I do glassfish redeploy I'm starting to get MySQLNonTransientConnectionException: could not create connection

I'm not sure if I can reproduce the problem without redeploying glassfish.

Any idea what could be causing problem and how to avoid it?

Mladen Adamovic
  • 3,071
  • 2
  • 29
  • 44
  • Looks like undeploy does not properly close all open database connections, on redeploy you then get twice as many open connections. See also http://stackoverflow.com/q/1392304/3080094 – vanOekel Feb 20 '14 at 14:40
  • Since that thread uses max 1 connection it could be more related to how DriverManager uses connection and glassfish does redeploy... haven't looked up into source code although... – Mladen Adamovic Feb 21 '14 at 14:58
  • although more interesting would be to hear how to avoid the problem.... if knowing cause it might be helpful... – Mladen Adamovic Feb 21 '14 at 14:59

0 Answers0