Several important parameters in Mysql JDBC URL

Source: Internet
Author: User


Mysql JDBC Driver
Two mysql drivers are commonly used. One is the mysql Driver provided by the gjt (Giant Java Tree) organization. The JDBC Driver name (JAVA class name) is org. gjt. mm. mysql. for Driver details, see website: http://www.gjt.org/ Or download the mysql JDBC Driver (mm. jar) from this website and the JDBC Driver officially provided by mysql. Its JAVA class name is com. mysql. jdbc. Driver. Download URL: http://dev.mysql.com/downloads/ To download MySQL ctor/J. Mysql jdbc url format: jdbc: mysql: // [host: port], [host: port].../[database] [? Parameter Name 1] [= parameter value 1] [& parameter name 2] [= parameter value 2]... currently, only a few important parameters are listed, as shown in the following table: parameter name parameter description the default value is the lowest version. The user database username (used to connect to the database) All versions of the password user password (used to connect to the database) whether all versions of useUnicode 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 gcharacterEncoding. When useUnicode is set to true, the character encoding is specified. For example, you can set it to gb2312 or gbk false 1.1 gautoReconnect. When the database connection is interrupted abnormally, will the database be automatically reconnected? False 1.1 autoReconnectForPools whether to use the reconnection policy for the database connection pool false 3.1.3failOverReadOnly after automatic reconnection is successful, is the connection set to read-only? When true 3.0.12maxReconnects autoReconnect is set to true, the number of retries is 3 1.1 When initialTimeout autoReconnect is set to true, the interval between two reconnections. 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.1socketTimeout socket operation (read/write) Timeout, in milliseconds. 0 indicates that the connection never times out. 0 3.0.1 corresponds to the Chinese environment. Generally, the mysql connection URL can be set to 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 jdbc: mysql: // localhost: 3306/test? User = root & amp; password = & amp; useUnicode = true & amp; characterEncoding = gbk & amp; autoReconnect = true & amp; failOverReadOnly = false author's cup of boiled water w

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.