The following article describes several important parameters in the Mysql jdbc url. We all know that there are several important parameters in the MySQL database, this article will also introduce its specific instances. I hope you can get some help through this article.
- MySQL JDBC Driver
There are two commonly used mysql drivers, one of which is gjtGiant Java Tree. The JDBC Driver name is JAVA class name): org. gjt. mm. mysql. Driver
Or download MysqlJDBC Driver (mm. jar)
The other is the JDBC Driver officially provided by MySQL. Its JAVA class name is com. mysql. jdbc. Driver.
Download MysqlConnector/J.
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]...
Only a few important Mysql jdbc url parameters are listed, as shown in the following table:
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 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=gbk&autoReconnect=true&failOverReadOnly=false
The above content describes several important parameters of the Mysql jdbc url. I hope it will help you in this regard.