0
votes

I`m in the development stage of an app and I don't make many server\cloud sql calls but for some reason I have an average of 400 usage hours a month.

When I look at the cloud sql active connections dashboard I see there is always at least one active connection but in the read\write operations it's usually on 0 besides the occasional small bumps.

I create a new connection each time I make a request to the server\cloud sql and close the connection each time when I return the response.

the connection code is(I followed the guestbook tutorial\example)

Class.forName("com.mysql.jdbc.GoogleDriver");
this.dbUrl  = "jdbc:google:mysql://trivia9991:triviadb?user=root";
this.dbConn = DriverManager.getConnection(dbUrl);

the closing connection code is

this.dbConn.close();

How can this keep a connection open at all time?

1

1 Answers

1
votes

If the connection close code is actually running this should not be the issue. You should make sure that the connection is closed even if an exception occurs before hand.

It is also possible that a connection you made using the MySQL command line client is still open.

You can examine what connections are open by connecting using the MySQL command line client and running a SHOW PROCESSLIST; statement.