So, I got this problem. I'm using JDBC, and every time if query get SQL exception and I/O error, the connection to pgsql database will be dropped automatically.
As a result, I have to check if the connection is open before every query, and if it's not open, I'll open it again.
Anyone knows why this is happening?
Also I know even I give perfect connection parameters, the connection could randomly drop.
Anyone knows how to set connection parameter to auto-check connections and reopen it in case connections down?
Currently I'm not using connection pooling.
Following is my code to set connection properties:
Properties pgsqlInfo = new Properties();
pgsqlInfo.setProperty("user", userName);
pgsqlInfo.setProperty("password", password);
pgsqlInfo.setProperty("ssl", "true");
pgsqlInfo.setProperty("loginTimeout", "0");
pgsqlInfo.setProperty("tcpKeepAlive", "true");
pgsqlInfo.setProperty("socketTimeout", "0");
con = (Connection) DriverManager.getConnection(url + "/" + dbName, pgsqlInfo);