1

I have scenario ,

If Below exception occurs in tomcat " java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] System resource exceeded."

Then Restart The Server .

Is there any possible solution .

Thanks

sharan jain
  • 85
  • 1
  • 11
  • Can you share the code where you create / use the connection? Sounds like a resource-leak to me you should fix instead of restarting the server if it happens. Do you have many places where this is throws or can you limit the numer of source placements? – Jan Jan 04 '16 at 12:29

1 Answers1

1

You've mentioned Bash, so one possibility is have a cron job which calls a shell script that reads the log every amount of x, searching for that exception, and if found restart Tomcat like this:

#!/bin/sh

results=`grep " java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] System resource exceeded." /path/to/tomcat.log

if [ ! -z "$results" ]
then
    service tomcat restart
fi

Issues with this are if Tomcat doesn't restart correctly how would you know. You would need to extend this to let you know that Tomcat has been restarted and/or check the service has restarted normally. You would also need some form of date checking or log renaming or everytime that log is read it could act upon previous cases of that Exception being logged.

But with Jan's comment on your question would probably be best to address the underlying issue of why are the system resources being exceeded (e.g. connection pooling, threads etc).

Crazy Dino
  • 808
  • 1
  • 8
  • 20