1. MySQL encounters garbled characters
Solution:Show variables like 'collation _ % ';
Check whether the encoding is the same as the data encoding in the program. If the encoding is different, there are two solutions:
A.
B. Set names 'gbk'
Alter database payment Character Set GBK;
Create Database mydb Character Set GBK;
Set character_set_client = GBK;
Set character_set_connection = GBK;
Set character_set_database = GBK;
Set character_set_results = GBK;
Set character_set_server = GBK;
Set character_set_system = GBK;
Set collation_connection = GBK;
Set collation_database = GBK;
Set collation_server = GBK;
2.Too many connectionsError
My c3p0 connection sets the maximum number of connections to 35, and then the access is no longer allowed after more than 30 times, and then promptsToo many connectionsError
The reason is that you forgot to close the connection !!!!!, After closing all OK
3. Differences between database connection and database connection pool in hibernate
When the database connection pool is not used, my access to the home page is very slow. The home page needs to wait for the database to query the content, about 30 ~ 50 seconds !!!
After the c3p0 connection pool is added, 4 ~ 10 seconds
4. In tomcat, the database connection is idle for 8 hours by default. If it is not used for 8 hours, it will be automatically disabled.
Solution: A. Restart tomcat. B. Restart MySQL and restart. C. Use c3p0 perfect solution (recommended) automatically reconnect when the database connection is closed