Even if the autoReconnecttrue parameter is added to the url when Mysql is created, the connection time exceeds the server wait_timeout time limit,
Even if the autoReconnect = true parameter is added to the url when Mysql is created, the connection time exceeds the server wait_timeout time limit,
1. even if the autoReconnect = true parameter is added to the url when Mysql is created, communication will still occur if the connection time exceeds the wait_timeout time limit on the server side: the last packet successfully received from the server was xxx milliseconds ago.
2. Server parameters can be used
Show global variables like 'wait _ timeout ';
Set global wait_timeout = 10;
But the value of wait_timeout should not be too high.
3. A better policy is to regularly send an SQL statement to the connection in the idle state to refresh the timestamp on the server. You can use the connection pool of c3p0r.
4. For the connection pool used in tomcat server. xml, use dbcp's connection pool at http://commons.apache.org/dbcp/configuration.html.
Type = "javax. SQL. DataSource" driverClassName = "com. mysql. jdbc. Driver"
Url = "jdbc: mysql: // localhost: 3306/test? CharacterEncoding = UTF-8"
Username = "root" password = "test" maxActive = "500" maxIdle = "10"
MaxWait = "-1" timeBetweenEvictionRunsMillis = "10000" minEvictableIdleTimeMillis = "10000"/>
4.1 set validationQuery, so that the validity of the connection will be verified through this SQL statement every time borrow (enabled by default), but the time is increased.
4.2 set timeBetweenEvictionRunsMillis = "10000" minEvictableIdleTimeMillis = "10000" depends on the evictor thread to close the timeout connection.
4.3 set testWhileIdle = "true" timeBetweenEvictionRunsMillis = "10000" validationQuery = "select 1" to periodically use query to detect connections in the idle state, thus refreshing the server time.
5. Maximum packet size submitted each time
Show global variables like 'max _ allowed_packet ';
Set global max_allowed_packet = 1024*1024;
6. Set connection parameters in SQLyog
6.1 set autocommit = 0 in SQLyog, so that the automatic commit of the current connection is false, and the transaction can be controlled.
6.2 begin; start of transaction
6.3 select * from test where 1 = 1 and id = 1 for update; in this way, the selected record row is locked, and then an SQLyog is opened to perform the same operations, wait will always be there.
6.4 commit; Submit
6.5 rollback; rollback
6.6 set autocommit = 0; and then add
Set transaction isolation level read committed;
In this way, other clients can see the commit data,
Question:
If set transaction isolation level read committed is not set; if both clients select the same data, one client modifies the data and submits the data. If the other client does not submit the current transaction, the select statement is executed, the data submitted by another client cannot be obtained, and the default transaction level of SQLyog is unknown.
7. check the mysql status in SQLyog. show global variables like '% lock %' is a good method. lock wait timeout exceeded is reported for the transaction Lock (for example, for update), which can only be modified by modifying my. the INI file innodb_lock_wait_timeout = 100; takes effect.
8. Change the User password mysqladmin-u root password "new_pass" in linux"
,