1: Install the JDK 2: Install Tomcat (This article is based on the Tomcat version 4.1.30 configuration, all of the other versions of the configuration are small.), And download the JDBC driver of the database you want to configure, put it $ TOMCAT_HOME $ / COMMON / LIB below. 3: Built a folder under WebApps under Tomcat installation directory, its name is assumed to foldername (the name of the folder can be arbitrarily named) 4: Built next to the folder (Foldername) to build a name for web-inf Folder, the name of this folder is fixed and cannot be named, and the name of the folder is capitalized. 5: There is a conf of the folder below the installation directory of Tomcat, there is a server.xml file, modify the same content of this file.
The specific modification method is to add the following contents between context> and host> in this file: factory name> org.apache.commons.dbcp.basicDataSourceFactory value > parameter> <-! Maximum number of dB connections in pool Make sure you configure your mysqld max_connections large enough to handle all of your db connections Set to 0 for no limit -...> MaxActive name> 100 value> parameter> maxidle name> 30 value> parameter> maxwait name> 10000 value> <
/ Parameter> <- To configure a DBCP DataSource so that abandoned dB connections are removed and recycled add the following paramater to the ResourceParams configuration for your DBCP DataSource Resource:! When available db connections run low DBCP will recover and recyle any abandoned dB connections IT Finds. The default is false. -> Removeabandoned name> true value> parameter> removeAbandonedTimeout name> 60 value> parameter> logabandoned name> true value> parameter> and password for db connections - -> Username name> root value> parameter> password name> Roger value> parameter> <
Name> driverclassname name> org.gjt.mm.mysql.driver value> parameter> url name> jdbc:.. mysql: / / localhost: 3306 / job? Autoreconnect = true value> parameter> resourceparams> context> 6: Replace the name of the created folder (Folder_name) replace the first line ( line) FolderName; 7: Simultaneously modify JDBC in the line / mysql "This value, modify it to the value you want to name, if you modify it to" JDBC / DatabaseConnection ", the value in the two rows of this is consistent, and is the same value. 8: Copy the downloaded JDBC driver to the COMMON / lib / directory below Tomcat, or add the JDBC driver to the classpath of the system. 9: Modify this driverclassname DRIVERCLASSNAMETER> DRIVERCLASSNAME Name> orgjt.mm.mysql.driver value> parameter> attribute value .
For example: Connect Oracle8 / 8i / 9i database (with Thin mode) should be modified as follows: driverclassname name> Oracle.jdbc.driver.Oracledriver value> parameter> Connect SQL Server7. 0/2000 database should be modified as follows: driverclassname name> com.microsoft.jdbc.sqlser.sqlserverDriver value> parameter> Connection DB2 database should be modified as results: Driverclassname name> com.ibm.db2.jdbc.app.db2driver value> parameter> Connecting the Informix database should be modified as follows: driverclassname name> com.informix .jdbc.ifxdriverr value> parameter> Connection Sybase database should be modified as follows: driverclassname name> com.sybase.jdbc.sybdriver value> parameter> Connection PostgreSQL database It should be modified as follows: driverclassname name> org.postgreSQL.Driver value> parameter> 10: Modify this URL according to the path of different databases / Name> JDBC: mysql: // localhost: 3306 / DatabaseName? AutoreConnect = true value> parameter> property value.
For example, it is Oracle8 / 8i / 9i database (with Thin mode), you should modify as follows: URL name> jdbc: Oracle: Thin: @localhost: 1521: Database_sid value > Parameter> SQL Server7.0 / 2000 database, you should modify as follows: URL name> JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = Pubs < / value> parameter> DB2 database, you should modify as follows: URL name> jdbc: db2: // localhost: 5000 / DatabaseName value> parameter> Informix database, you should modify as follows: URL name> jdbc: informix-sqli: //123.45.67.89: 1533 / databasename: InformixServer = myserver value> parameter > Sybase database, you should modify as follows: URL name> JDBC: Sybase: TDS: localhost: 5007 / DatabaseName value> parameter> 11: in Web-INF The folder is built under the folder, its name is web.xml, the name of this file is also fixed, can not be named, and the name of the file is lowercase.