Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Virtual Hosting & Database Pooling not working

Matt Anderson

2004-04-27


Hello all, I seem to be having a problem with virtual hosting and database
pooling. I originally had the context for a website all within the default
host, I put some datasources in there to connect to an oracle database.
This worked great however I recently put a new domain on and implemented
virtual hosting, so I moved the datasource into the new host for that
domain. Now I seem to be getting a naming exception when I attempt to
reference it. Here is some snippets of code: -

//This is where I originally gained a reference to
//the data source and this worked fine
try
  {
   Context ctx = new InitialContext();
   DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/sun");
   return ds.getConnection();
  }
  catch(NamingException e)
  {
   e.printStackTrace();
   return null;
  }


I have pretty much the same information in the ROOT.xml regarding the
resources, here is the header info of it.

<Resource name="jdbc/sun" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/sun">

The web.xml file has not changed as I didn't see any need to.

Does the lookup have to reference elsewhere once virtual hosting has been
implemented? I really look forward to your responses as I seem to be a
little confused as to why this is not working.

Thanks for your time and I look forward to hearing from you.

Kindest Regards,
Matt Anderson

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.