Question

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?

Was it helpful?

Solution 3

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.

OTHER TIPS

May it be that a connection limit to the database was reached?

I don't know why you would get that specific message, but given that you can initially connect, and the amount of time that goes by before you experience the problem, your MySQL connection may be timing out. Try appending ?autoReconnect=true to your JDBC URL and see if that resolves the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top