MySQL garbled and problems encountered during development

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.