Note |
---|
Keep in mind, you must always supply the correct values for your database in the following attributes: password, username, url, and driverclassname |
1 Tomcat 5.5.x, 6.0.x, 7.0.x
The following shows an example Tomcat 5.5.x, 6.0.x or 7.0.x web context xml file with data source definition for an Oracle database:
Code Block |
---|
title | Example Tomcat Context file with Data Source Definition for Oracle |
---|
|
<Context reloadable="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/*</WatchedResource>
<Resource
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
name="jdbc/DARS"
password="thepassword"
username="theuser"
url="jdbc:oracle:thin:@localhost:1521:XE"
validationQuery="select 1 from dual"
maxIdle="4"
maxActive="8"
autoCommit="false" />
</Context> |
The following shows an example Tomcat 5.5.x, 6.0.x or 7.0.x web context xml file with data source definition for a SQL Server database:
Code Block |
---|
title | Example Tomcat Context file with Data Source Definition for SQL Server using the JTDS driver |
---|
|
<Context reloadable="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/*</WatchedResource>
<Resource
auth="Container"
type="javax.sql.DataSource"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
name="jdbc/DARS"
password="thepassword"
username="theuser"
url="jdbc:jtds:sqlserver://localhost/dars35"
validationQuery="select 1"
maxIdle="4"
maxActive="8"
autoCommit="false" />
</Context> |
The following shows an example Tomcat 5.5.x, 6.0.x or 7.0.x web context xml file with data source definition for a DB2 database:
Code Block |
---|
title | Example Tomcat Context file with Data Source Definition for DB2 |
---|
|
<Context reloadable="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/*</WatchedResource>
<Resource
auth="Container"
type="javax.sql.DataSource"
driverClassName="COM.ibm.db2.jdbc.app.DB2Driver"
name="jdbc/DARS"
password="thepassword"
username="theuser"
url="jdbc:db2:yourdatabase"
validationQuery="SELECT 1 FROM sysibm.sysdummy1"
maxIdle="4"
maxActive="8"
autoCommit="false" />
</Context> |
2 Tomcat 8.0.x, 8.5.x, 9.0.x
Choose one of the above Tomcat web context xml files based on your database type and add the following xml above the <WatchedResource> elements.
Code Block |
---|
<JarScanner>
<JarScanFilter tldScan="displaytag-1.1.jar,freemarker-2.3.15.jar,jawr-3.3.3.jar,jtidyservlet-r8.jar,sitemesh-2.4.2.jar,spring-modules-validation-0.8a.jar,spring-webmvc-3.0.6.RELEASE.jar,standard-1.1.2.jar,unstandard-1.0.jar"/>
</JarScanner> |
The following shows an example Tomcat 8.0.x, 8.5.x or 9.0.x web context xml file with data source definition for an Oracle database:
Code Block |
---|
<Context reloadable="true">
<JarScanner>
<JarScanFilter tldScan="displaytag-1.1.jar,freemarker-2.3.15.jar,jawr-3.3.3.jar,jtidyservlet-r8.jar,sitemesh-2.4.2.jar,spring-modules-validation-0.8a.jar,spring-webmvc-3.0.6.RELEASE.jar,standard-1.1.2.jar,unstandard-1.0.jar"/>
</JarScanner>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/*</WatchedResource>
<Resource
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
name="jdbc/DARS"
password="thepassword"
username="theuser"
url="jdbc:oracle:thin:@localhost:1521:XE"
validationQuery="select 1 from dual"
maxIdle="4"
maxActive="8"
autoCommit="false" />
</Context> |