Search code examples
scalatomcatintellij-ideasqueryl

Scala and squeryl MySQL connection drops and cannot reconnect after about 10 minutes


I create a mysql connection with the following lines successfully

Factory Session Code

val session = Session.create(
                  DriverManager.getConnection(url, user, pass),
                  new CustomMySqlAdapter
              )

I am using Intellij Ultimate IDEA's Tomcat server. The build configuration creates a war and deploys to my local tomcat perfectly. After a certain amount of time, about 10 minutes, the connection drops and never recovers. As I debug, this line craps out and throws

Exception Thrown

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 5 times. Giving up.

It seems to be DriverManager.getConnection(url, user, pass) even though those variables haven't changed since the last successful connection. How can I trouble shoot this? Is this a space issue? Even after this error is thrown the server is still running without successfully connecting to the database. It is simply barfing this line again and again.

I can still connect locally to mysql via command line. I killed all the open connection with not avail. While running a memory profile tool, it seems that PermGen is maxing out.

PermGen Stats

Size: 70,844,416 B
Used: 70,674,400 B
Max: 1,073,741,824 B

Can I up PermGem in intellij to solve this? If so, how?


Solution

  • Despite where the evidence pointed, the issue was a hard drive space issue.

    I backed up my database. Stopped mysql. I deleted ibdata1 file. Restarted my computer. Reimporting my database.

    Hope this helps someone else.