I'm quite new to Tomcat but I have configured a Datasource in it without too
much hassle. Im not really up on Tomcat logging so I will leave that for
someone else. If you know about datasources than now is a good time to stop
reading. :)
Here is what I did for the datasource:
In my server.xml file I have defined a new context for my webapp (some
values have been changed for security) :)
<Context path="/main" docBase="main" debug="5" reloadable="true"
crossContext="true">
<Logger className="
org.apache.catalina.logger.FileLogger"
prefix="localhost_db2db_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/db2db" auth="Container" type="
javax.sql.DataSource"/>
<ResourceParams name="jdbc/db2db">
<parameter>
<name>factory</name>
<value>
org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!--
Class name for DB2 JDBC driver
-->
<parameter>
<name>driverClassName</name>
<value>com.ibm.as400.access.AS400JDBCDriver</value>
</parameter>
<!--
The JDBC connection url for connecting to the DB2 database.
-->
<parameter>
<name>url</name>
<value>jdbc:as400://db2dbserver/DBNAME</value>
</parameter>
<!--
DB2 database username and password for database connections
-->
<parameter>
<name>username</name>
<value>db2user</value>
</parameter>
<parameter>
<name>password</name>
<value>db2passowrd</value>
</parameter>
<!--
Maximum number of dB connections in pool. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<!--
Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<!--
Maximum time to wait for a dB connection to become available
in ms. An Exception is thrown if this timeout is exceeded.
Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>30000</value>
</parameter>
</ResourceParams>
</Context>
In my DAOing app i used code somewhat different to the following to create a
datasource (convienience abstractions and configuration modules and logging
removed for your convenience):
try {
// Obtain the JNDI context
Context ctx = new InitialContext();
if (ctx != null) {
// Lookup the datasource
db2DataSource =
(DataSource)ctx.lookup("java:comp/env/jdbc/db2db");
}
} catch (NamingException ne) {
// Log error
log.error("Unable to obtain datasource java:comp/env/jdbc/db2db", ne);
}
Regards,
Shane.
-----Original Message-----
From: Tim.Adler@(protected)]
Sent: Wednesday, 28 April 2004 4:27 PM
To: tomcat-user@(protected)
Subject: DataSource-Configuration and Debug-Output
Hello everybody!
I'm trying to migrate my webapp from JBOSS to Tomcat. I know sounds unusual,
but since I don't use any EJB or JMS or whatever features of JBOSS and only
need DBPooling and a Servlet/JSP 2.0 Container, I thought it would be easier
to use a standalone Tomcat.
I'm having difficulties doing two things:
1. Configuring a working DataSource/DB Pool. I've read several topics about
this issue now. I configured the DataSource through the Admin-Console.
Committed the changes and restarted. By my webapp still tells me that the
DataSource is not bound in the JNDI-Context. I named my datasource "DiasDB"
and tried to access it through that name, but no luck. I also tried several
prequels like "java:/" or "jdbc/" no luck either. What is the issue here?!
2. I would like Tomcat to do more output about what it is doing. Like the
big DEBUG-server-log that JBOSS is writing. I have set every Logger to
highest Debug and Verbosity-Levels, but still there is only INFO out in the
catalina.out or localhost***.txt. I was hoping to find any message that the
DataSource is succesfully deployed there, but I can find nothing. How is the
DEBUG-mode activated?!
Thx for any help!!
_______________________________________
Tim Adler, Abt. SDA1
Adress Management Solutions
AZ | Direct
Carl-Bertelsmann Stra�e 161s
D-33311 G�tersloh
Tel.: 05241/ 80 - 89574
tim.adler@(protected)
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)