MySql url parameters _ MySQL

Source: Internet
Author: User
Detailed description of MySql url parameters

MySql url parameters

I recently sorted out the settings of MySql url parameters on the internet. I hope you can give me some advice on the following:

The URL format of mysql JDBC is as follows:

Jdbc: mysql: // [host: port], [host: port].../[database] [? Parameter name 1] [= parameter value 1] [& parameter name 2] [= parameter value 2]...

Common important parameters:

Parameter name parameter description default value minimum version requirements

User Database username (used to connect to the database) all versions

PassWord user passWord (used to connect to the database) all versions

Whether useUnicode uses the Unicode character set. if the characterEncoding parameter is set to gb2312 or gbk, the value of this parameter must be set to true false 1.1g.

CharacterEncoding specifies the character encoding when useUnicode is set to true. For example, you can set it to gb2312 or gbk false 1.1g.

Is autoReconnect automatically reconnecting when the database connection is interrupted abnormally? False 1.1

Whether autoReconnectForPools uses the reconnection policy for the database connection pool false 3.1.3

After failOverReadOnly is automatically reconnected, is the connection set to read-only? True 3.0.12

When maxReconnects autoReconnect is set to true, the number of retries is 3 1.1.

The time interval between two reconnections when initialTimeout autoReconnect is set to true. unit: Second 2 1.1

The timeout value for establishing a socket connection between connectTimeout and the database server, in milliseconds. 0 indicates never timeout, applicable to JDK 1.4 and later version 0 3.0.1

The socketTimeout socket operation (read/write) times out. unit: milliseconds. 0 indicates never timeout. 0 3.0.1

The connection URL of mysql can be set:

Jdbc: mysql: /// localhost: 3306/test? User = root & password = & useUnicode = true & characterEncoding = utf8 & autoReconnect = true & failOverReadOnly = false

When using the database connection pool, it is best to set the following two parameters:

AutoReconnect = true & failOverReadOnly = false

Note that in the xml configuration file, the & symbol in the url must be converted &. For example, when you configure the database connection pool in tomcat server. xml, the mysql jdbc url sample is as follows:

Jdbc: mysql: /// localhost: 3306/test? User = root & password = & useUnicode = true & characterEncoding = utf8 & autoReconnect = true & failOverReadOnly

BitsCN.com

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.