tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: How To Unit Testing Tomcat Datasource
Date Wed, 19 Feb 2003 18:14:17 GMT
Always use java:comp/env/yourdatasource

"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-----Original Message-----
From: Haytham Samad [] 
Sent: February 19, 2003 1:13 PM
To: Tomcat Users List
Subject: How To Unit Testing Tomcat Datasource

I have set up a datasource in Tomcat's server.xml using dbcp.  It works
fine, I get connections connect to the database, etc.  Now, I am in the
process of putting together quite a bit of DAO code and would like to unit
test each call as I am going through the coding using my JUnit tests.  How
can I connect to Tomcat's JNDI and get a reference to the datasource there
to pass to the classes I am testing?  Or should I just rework my test code
to just create a connection from the DriverManager and go from there?
Anybody doing anything like this with suggestions?  I appreciate any

BTW:  I tried to connect to Tomcat's JDNI using the InitialContext and that
did not work because I could not get a datasource.



To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message