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