Question about MySQL connection pool and tomcat

Source: Internet
Author: User
Tags mysql connection pool

This article mainly describes the detailed analysis of problems related to tomcat (a very useful JSP running platform) and MySQL connection pool. After a day of research, I finally learned something about it, I hope it will be helpful to you. First, please note:

Here we will particularly discuss the problems encountered in tomcat (a very useful JSP running platform) Version 5.5. Why is this version especially special? I will explain it later.

Problem 1: Cannot create JDBC driver of class ''for connect URL 'null'

A:

[Cause Analysis]

Many friends are configuring $ tomcat (a very useful JSP running platform)/conf/server. xml (standardization is getting closer and closer), $ tomcat (a very useful JSP running platform)/conf/context. xml (standardization is getting closer and closer), and even WEB-INF/web. xml (standardization is getting closer and closer), and the above error occurs when MySQL connection pool is called.

The cause of the error is analyzed. This is generally because you do not specify a data source (the actual cause is that driverClassName and url are set to null, but you will certainly not forget to set this field, so it must have been set up and no connection is available !). Usually there are two ways to configure the Data source: $ tomcat (a good JSP running platform)/conf/context. xml (standardization is getting closer and closer)

One is to add the following code before $ tomcat (a good JSP running platform)/conf/server. xml (standardization is getting closer and closer) </GlobalNamingResources>:
Method 1:

 
 
  1. <Resource 
  2. name="jdbc/test"  

Data Source Name

 
 
  1. type="javax.sql.DataSource" 

DriverClassName = "com. MySQL (the best combination with PHP). jdbc. Driver"

This is the driverClassName settings I just mentioned.

 
 
  1. password="admin"  

Database Password

 
 
  1. maxIdle="2" 
  2. maxWait="5000" 
  3. username="root"  

Database username

Url = "jdbc: MySQL (the best combination with PHP ):

 
 
  1. localhost:3306/test?autoReconnect=true"  

Database URL, which is the url just mentioned

 
 
  1. maxActive="4"/> 

In addition to comments, all parameters are set for the number of connections, idle status, and activity status. If you are only doing a learning test, you do not have to change it. This method is equivalent to configuring operations in the tomcat (a good JSP running platform) GUI.

The above content is a detailed description of Tomcat and MySQL connection pool issues, hoping to provide you with some help in this regard.

Related Article

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.