The following describes the MySql connection string parameters and formats for your reference. If you are interested in the MySql connection string, take a look.
Two mysql JDBC drivers are commonly used. One is the mysql Driver provided by gjtGiant Java Tree. The JDBC Driver name is JAVA class name.
The other is the JDBC Driver officially provided by mysql. Its JAVA class name is com. mysql. jdbc. Driver.
The URL format of mysql JDBC is as follows:
Jdbc: mysql: // [host: port]/[database] [? Parameter Name 1] [= parameter value 1] [& parameter name 2] [= parameter value 2]...
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 |
UseUnicode |
Whether to use 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.1 GB |
CharacterEncoding |
Specify the character encoding when useUnicode is set to true. For example, you can set it to gb2312 or gbk. |
False |
1.1 GB |
AutoReconnect |
Will the database be automatically reconnected when the database connection is interrupted abnormally? |
False |
1.1 |
AutoReconnectForPools |
Whether to use the reconnection policy for the database connection pool |
False |
3.1.3 |
FailOverReadOnly |
After automatic reconnection is successful, is the connection set to read-only? |
True |
3.0.12 |
MaxReconnects |
Number of Retries when autoReconnect is set to true |
3 |
1.1 |
InitialTimeout |
The interval between two reconnection attempts when autoReconnect is set to true. Unit: seconds. |
2 |
1.1 |
ConnectTimeout |
Timeout when establishing a socket connection with the database server, in milliseconds. 0 indicates never timeout. Applicable to JDK 1.4 and later versions. |
0 |
3.0.1 |
SocketTimeout |
Socket operation read/write) Timeout, in 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 = gbk & 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 the & symbol in the url must be escaped in the xml configuration file. 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 & amp; password = & amp; useUnicode = true & amp; characterEncoding = gbk
& Amp; autoReconnect = true & amp; failOverReadOnly = false
Introduction to mysql trigger new old
Three examples of mysql triggers
How to Create a master-slave server for mysql
Obtain the MySql time function of the current time
Mysql Aggregate functions