Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see / change MySQL connection timeout settings?

Tags:

I have a Java program. When I log in, after ~600,000 milliseconds (I actually tried several times, and it is always ~600,000. That is why I think there is 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()    {         try{             Class.forName("com.mysql.jdbc.Driver");             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 ?autoReconnect=true & tcpKeepAlive to my code, but no luck. Is there any way to go to phpmyadmin and change some setting there (increase the timeout time)?

like image 690
Edgar Avatar asked Apr 24 '13 12:04

Edgar


People also ask

Where can I find MySQL connection details?

mysql> SELECT CONNECTION_ID(); The following is the output that shows the current connection id. The following is the syntax to check all the current information with a single command.

How do I change the connection timeout in MySQL Workbench?

Can I adjust the timeout? Yes, go to Preferences, SQL Editor, and adjust the DBMS connection read time out option that defaults to 600 seconds. This sets the maximum amount of time (in seconds) that a query can take before MySQL Workbench disconnects from the MySQL server.


1 Answers

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'; 
like image 120
Ömer Faruk Almalı Avatar answered Sep 20 '22 19:09

Ömer Faruk Almalı