Edgar Edgar - 1 year ago 136
MySQL Question

How can i see / change MySQL connection timeout settings?

I have a java program, when i log in, after ~600,000 milliseconds (i actually tried several times, and its always ~600,000, thats why i think theres somewhere set up a timeout for 600,000 miliseconds) my database connection crashes and my program no longer works (it always needs to be connected to database). It gives me

Communication link failure
error. I Here are my mysql connection settings:

import java.sql.*;
import javax.swing.*;
public class mysqlconnect {
Connection conn = null;
public static Connection ConnectDb() {
Connection conn = DriverManager.getConnection("jdbc:mysql://server_name/database_name","user_name","user_password");
return conn;
}catch (Exception e) {
JOptionPane.showMessageDialog(null, "Cant connect to db");
return null;

I tried adding
to my code, but no luck. Is there any way to go to phpmyadmin and change some setting there (increase the timeout time)?

Answer Source
SET SESSION wait_timeout = 999999;//or anything you want

From mysql command line that will increase the timeout value. To be able to see the value:

SHOW VARIABLES LIKE 'wait_timeout';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download