commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Getting DBCP working through Tomcat 4.1
Date Wed, 19 Jan 2005 09:00:13 GMT
Hello all, and apologies if I am asking a question which has been asked
before (I presume it has but I can't find anything after comprehensive

I am trying to get a simple Tomcat application up using DBCP, and got
BasicDataSource working fine. However, our applications all run under
their own identities, and therefore need to be able to get connections
based on username. I have tried using PerUserPoolDataSource and
SharedPoolDataSource with no luck. The exception I am currently getting
is as follows:
"Must set the ConnectionPoolDataSource through setDataSourceName or
setConnectionPoolDataSource before calling getConnection"

My configuration is as follows:
Tomcat 4.1.24, DBCP 1.2.1, Sybase jConnect 5.0 build 10229 (Sybase and
DBCP jars in <tomcat_base>/common/lib)

Following is an extract of my configuration files, and application code.
I would greatly appreciate some help - this is beginning to drive me

Thanks in advance,

Server.xml extract:
	<Resource name="jdbc/TestDB" auth="Container"
	<ResourceParams name="jdbc/TestDB">

Application code extract

ctx = new InitialContext();

DataSource ds = null;
if (ctx != null) {
	ds = (DataSource) ctx.lookup("java:comp/env/jdbc/TestDB");
	Connection conn = ds.getConnection(userName, passWord);  //
<---- exception on this line

	Statement stm = conn.createStatement();
	ResultSet results = stm.executeQuery("select db_name()");

	if (
		out.write("Successfully connected to database " +

For more information about Barclays Capital, please
visit our web site at

Internet communications are not secure and therefore the Barclays 
Group does not accept legal responsibility for the contents of this 
message.  Although the Barclays Group operates anti-virus programmes, 
it does not accept responsibility for any damage whatsoever that is 
caused by viruses being passed.  Any views or opinions presented are 
solely those of the author and do not necessarily represent those of the 
Barclays Group.  Replies to this email may be monitored by the Barclays 
Group for operational or business reasons.


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

View raw message