You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Richards <nc...@pobox.com> on 2001/10/03 21:10:17 UTC

2 webapps 2 jars 1 driver?

Ok I am running two applications that use the IBM DB2 appdriver to connect
to two different databases.  The problem is this when i start up tomcat only
one of the applications can access the database.  The first one to have a
request made wins and the other app gets a No Suitable Driver exception.
They both work independtly as long as it's the first one requested.  My
theory is that the Class.forName(driver) being called twice is mucking
things up the code at fault is:

The obeject that owns this code is instatiated in in jspInit() and load is
called only once.

Any other theories?

Thanks

Brian

ps
I'm using Tomcat 3.3, jdk1.3.1 WIN2k. and Apace 1.3.6
and the two applications are in two different virtual hosts

<Context path="/" docBase="E:/csc/513/htdocs" debug="0" reloadable="true"
trusted="false"/>

<Host name="dafs.dyndns.org" >
            <Context path="/messages" docBase="webapps/jive" debug="0"
reloadable="false" trusted="false"/>
</Host>

but i get teh same error when they are both in the same host.



public Connection driverManager()
 throws SQLException
 {
  return  DriverManager.getConnection(getURL(), getUserID(), getPassword());
 }

 public boolean load(Properties prop)
 {
  if (prop!=null) {
   try {
    driver = (String)prop.get("driver");
    password = (String)prop.get("password");
    URL = (String)prop.get("url");
    userID = (String)prop.get("user");
    dataSourceName = (String)prop.get("datasource");
    try {
     Class.forName(getDriver());
    } catch (ClassNotFoundException cnfe) {
     System.err.println(getDriver()+" could not be found.");
    }
   } catch (NullPointerException npe) {
    return false;
   }
  }
  return true;
 }