Break through the JNDI connection pool (configure the connection pool through the Management Interface in tomcat5.5)

Source: Internet
Author: User
Tags microsoft website
I. put the three JDBC drivers under tomcat_home/common (yes). You can download them from the Microsoft website. The default username for installing sqlserver2k is SA and the password is blank, if the password is empty, it does not mean that there is no password. Therefore, you must define username and password in your url. It is best to reset the password.
II. if a reference error occurs, the path is not correctly written. The default Tomcat path is atat_home/webapps/. However, if 5.5.x is used, use the following method without configuring the path, and it does not need to be in youwebapp/WEB-INF/web. XML file configuration reference
III. tomcat5.5.x server. the xml configuration is different from the tomcat5.0 configuration. The following lists three configuration methods in tomcat5.5.x. If the configuration is incorrect, javax appears. naming. namenotfoundexception: Name is not bound in this context Error
Method 1: Global Database Connection Pool
1. Configure the connection pool through the management interface, or directly add
<Resource Name = "JDBC/mydb" type = "javax. SQL. datasource "Password =" mypwd "driverclassname =" com. microsoft. JDBC. sqlserver. sqlserverdriver "maxidle =" 2 "maxwait =" 5000 "validationquery =" select 1 "username =" sa "url =" JDBC: Microsoft: sqlserver: // localhost: 1433; databasename = mydb "maxactive =" 4 "/>
2. Add the following in the context of Tomcat/webapps/MyApp/META-INF/context. xml:
<Resourcelink global = "JDBC/mydb" name = "JDBC/mydb" type = "javax. SQL. datasource"/>
In this way, you can.
Method 2: Global Database Connection Pool
1. Same as above
2. Add the following content to the context of Tomcat/CONF/context. xml:
<Resourcelink global = "JDBC/mydb" name = "JDBC/mydb" type = "javax. SQL. datasource"/>
Method 3: Local Database Connection Pool
Just add the following to the context of Tomcat/webapps/myapps/META-INF/context. xml:
<Resource Name = "JDBC/mydb" type = "javax. SQL. datasource "Password =" mypwd "driverclassname =" com. microsoft. JDBC. sqlserver. sqlserverdriver "maxidle =" 2 "maxwait =" 5000 "validationquery =" select 1 "username =" sa "url =" JDBC: Microsoft: sqlserver: // localhost: 1433; databasename = mydb "maxactive =" 4 "/>
Parameter description:
Driveclassname: full name of the JDBC Driver Class;
Maxactive: Maximum number of available instances that can be allocated from the connection pool;
Maxidle: Maximum number of connections that can be idle in the connection pool at the same time;
Maxwait: Maximum timeout in milliseconds;
Password: user password;
URL: URL Connection to JDBC;
User: user name;
Validationquery: Used to query idle connections in the pool.
The preceding three methods can be used in Tomcat 5.5.4. In addition, the JDBC driver of SQL Server is the SQL Server JDBC (SP3) downloaded from the Microsoft website ).
4. org. apache. tomcat. DBCP. DBCP. sqlnestedexception: cannot create poolableconnectionfactory ([Microsoft] [sqlserver 2000 driver for JDBC] Error establishing socket .) this is a small problem, because my sqlserver2k service is changed to manual, so we need to manually start sqlserver2k every time after startup. Because I did not remember the startup at once, I reported some errors, so if you often use sqlserver2k, you 'd better not manually start it.

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.