Installing the DataSource into J2EE/Tomcat
Information on how to configure a DataSource in the J2EE/Tomcat container can be found in the corresponding J2EE/Tomcat documentation. For example, to configure a H2 DataSource in Tomcat:
-
Download the H2 driver jar (h2-1.3.165.jar) and put it into CATALINA_HOME/lib directory.
-
Add a Resource entry for the H2 DataSource to the CATALINA_HOME/conf/context.xml:
<Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource" username="sa" password="" driverClassName="org.h2.Driver" url="jdbc:h2:tcp://localhost/~/test" maxActive="8" maxIdle="30" maxWait="10000"/>
The JNDI DataSource name jdbc/datasource is available to be used in the Service Activity Monitoring Server.
Here are Resource entries for other databases:
-
Derby:
<Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="org.apache.derby.jdbc.ClientDriver" url="jdbc:derby://localhost:1527/db;create=true" maxActive="8" maxIdle="30" maxWait="10000"/>
-
MySql:
<Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test" maxActive="8" maxIdle="30" maxWait="10000"/>
-
DB2:
<Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource" username="db2admin" password="qwaszx" driverClassName="com.ibm.db2.jcc.DB2Driver" url="jdbc:db2://localhost:50000/TEST" maxActive="8" maxIdle="30" maxWait="10000"/>
-
SQLServer:
<Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:1029;instanceName=sqlexpress;datab aseName=Test" maxActive="8" maxIdle="30" maxWait="10000"/>
-
Oracle:
<Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource" username="xxx" password="xxx" driverClassName="oracle.jdbc.pool.OracleDataSource" url="jdbc:oracle:thin:@localhost:1521:XE" maxActive="8" maxIdle="30" maxWait="10000"/>
-
PostgreSQL:
<Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource" username="postgres" password="qwaszx" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/" maxActive="8" maxIdle="30" maxWait="10000"/>