Tomcat data source configuration

xiaoxiao2021-03-05  29

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 and in this file: factory org.apache.commons.dbcp.basicDataSourceFactory <-! 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 100 maxidle 30 maxwait 10000 <

/ 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 true removeAbandonedTimeout 60 logabandoned true and password for db connections - -> Username root password Roger <

Name> driverclassname org.gjt.mm.mysql.driver url jdbc:.. mysql: / / localhost: 3306 / job? Autoreconnect = true 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 orgjt.mm.mysql.driver attribute value .

For example: Connect Oracle8 / 8i / 9i database (with Thin mode) should be modified as follows: driverclassname Oracle.jdbc.driver.Oracledriver Connect SQL Server7. 0/2000 database should be modified as follows: driverclassname com.microsoft.jdbc.sqlser.sqlserverDriver Connection DB2 database should be modified as results: Driverclassname com.ibm.db2.jdbc.app.db2driver Connecting the Informix database should be modified as follows: driverclassname com.informix .jdbc.ifxdriverr Connection Sybase database should be modified as follows: driverclassname com.sybase.jdbc.sybdriver Connection PostgreSQL database It should be modified as follows: driverclassname org.postgreSQL.Driver 10: Modify this URL according to the path of different databases / Name> JDBC: mysql: // localhost: 3306 / DatabaseName? AutoreConnect = true property value.

For example, it is Oracle8 / 8i / 9i database (with Thin mode), you should modify as follows: URL jdbc: Oracle: Thin: @localhost: 1521: Database_sid SQL Server7.0 / 2000 database, you should modify as follows: URL JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = Pubs < / value> DB2 database, you should modify as follows: URL jdbc: db2: // localhost: 5000 / DatabaseName Informix database, you should modify as follows: URL jdbc: informix-sqli: //123.45.67.89: 1533 / databasename: InformixServer = myserver Sybase database, you should modify as follows: URL JDBC: Sybase: TDS: localhost: 5007 / DatabaseName 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.

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

New Post(0)