Several important parameter descriptions about JDBC URL in MySQL

Source: Internet
Author: User

This article will introduce some important parameters of JDBC URL in MySQL, here will also introduce some concrete examples, I hope you can get some help through this article.

MySQL JDBC Driver

There are two commonly used, one is the MySQL driver provided by the GJT (Giant java tree), and its JDBC Driver name (Java class name) is: Org.gjt.mm.mysql.Driver

For more information, see Web site: http://www.gjt.org/

or download MySQL JDBC Driver on this site (Mm.jar)

The other is the MySQL official JDBC Driver, whose Java class name is: Com.mysql.jdbc.Driver

Driver Download URL: http://dev.mysql.com/downloads/, into which the MySQL connector/j area to download.

The MySQL JDBC URL format is as follows:

jdbc:mysql://[host:port],[host:port].../[database][argument name 1][= parameter value 1][& parameter name 2][= argument value 2] ...

There are only a few important MySQL JDBC URL parameters listed here, as shown in the following table:

For the Chinese environment, the MySQL connection URL can usually be set to:

jdbc:mysql://localhost:3306/test? user=root&password=&useUnicode=true&characterEncoding=gbk&autoReconnect=true &failOverReadOnly=false

In the case of using a database connection pool, it is best to set the following two parameters:

autoReconnect=true&failOverReadOnly=false

It should be noted that in the XML configuration file, the & symbol in the URL needs to be escaped to &. For example, when configuring a database connection pool in Tomcat's server.xml, the MySQL JDBC URL sample is as follows:

jdbc:mysql://localhost:3306/test? user=root&password=&useUnicode=true&characterEncoding=gbk
&am p;autoReconnect=true&failOverReadOnly=false

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.