mysql 查看设置连接时间,如何查看/更改MySQL连接超时设置?

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() {

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)?

解决方案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';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值