Tomcat5 database connection pool configuration [转]

xiaoxiao2021-03-06  40

Tomcat 5.0.14 The database connection pool configuration, and the common problem and solution of the JNDI search, configuration, and application process of the program.

1. Configure the environment: Tomcat5.0.14 JDK1.42 SQL Server 2000 Win2003 2. Configuration steps:

first step:

Start Tomcat, open IE Enter http: // localhost: 8080 / admin to enter Tomcat management interface in the address bar; click on the drop-down menu on the right side to select Create New Data Source in the lower right input box. Configuration information.

JNDI NAME: JDBC / XXX (XXX is the name yourself ")

Data Source URL: JDBC: Microsoft: SQLSERVER: // localhost: 1433; DatabaseName = Tempdb (connected data name)

JDBC Driver Class: com.microsoft.jdbc.sqlserver.sqlserverdriver

User name: User name to connect to the database

Password: Database password

Max. Active Connections: Maximum connection

Max. Idle Connections: is the maximum number of idle connections

Max. Wait for Connection: Maximum Waiting Connection

Step 2: Configure Web.xml Open Web.xml under WebApps / Root / Web-INF, add the following: SQLServer Datasource Example JDBC / SQLServerDB javax.sql.datasource Container

Step 3: Configure Tomcat (add classes)

First you want to download the installation of SQLSerVer-JDBC-driver, then put the three JAR files under its lib.

Under Tomcat / Common / LIB.

Precautions:

If we are a single JSP page we put it under Tomcat_Home / WebApps / root, but also need to modify the root.xml file under Tomcat_Home / Conf / Catalina / LocalHost /

Add:

To reference the configured JNDI data source. At the same time, Comment If we are going to deploy a web application, we will apply The program is placed in the Tomcat_Home / WebApps directory, there are two ways to reference the JNDI data source we have configured.

A: You can create a new xxx.xml file under Tomcat_Home / CONF / CATALINA / LOCALHOST, XXX is the name of the released web application, such as the web application I posted is jnditest, .xml file named jnditest.xml in this file plus:

factory

org.apache.commons.dbcp.basicDataSourceFactory

Password

jsjrj

maxactive

4

maxwait

5000

URL

JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = Tempdb

driverclassname

com.microsoft.jdbc.sqlser.sqlserverdriver

Username

sa

maxidle

2

Where E: / Tomcat 5.0 / WebApps / Jnditest is a directory for your publishing application, so you can test it.

Doing this is that every web application must create a file like JNDITEST.XML.

B; To avoid each web application to create a xxx.xml file, we can modify the server.xml file under Tomcat_Home / Conf, modify the following:

Join between :

URL jdbc: microsoft: sqlserver: // localhost: 1433; DatabaseName = Content driverclassname com.microsoft.jdbc.sqlser.sqlserverdriver maxwait 10000 maxactive 50 password Content maxidle 2 username content

factory org.apache.commons.dbcp.basicDataSourceFactory For my CMS system, modify PropertySet.xml < propertyset name = "map" class = "com.opensymphony.module.propertyset.map.MapPropertySet" />

value = "net.sf.hibernate.dialect.SQLServerDialect" /> there dataAccessContext .xml net.sourceforge.jtds.jdbc.Driver jdbc: jtds: sqlserver: // localhost: 1433 / content; charset = gbk Content < / value> content from Blog:

http://blog.9cbs.net/fiveesky/

转载请注明原文地址:https://www.9cbs.com/read-82630.html

New Post(0)