tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Sowa <>
Subject problem with JNDI
Date Fri, 03 Feb 2006 11:40:04 GMT

I'm working on a webapplikation using JNDI to lookup for a database
connection. Actually it works for several times and then it stopps and I
don't get an connection. I analysed it and found out that Method
getConnnection has a problem.

Here is my code:

protected Connection lookupJNDIConnection(final String resource) {
        InitialContext ic = null;
        try {
            System.out.println("will InitialContext");
            ic = new InitialContext();
            System.out.println("lookup nach comp/env");
            Context envContext = (Context) ic.lookup("java:/comp/env");
            DataSource ds = (DataSource) envContext.lookup(resource);
            System.out.println("return getconnection.");
            return ds.getConnection();

        } catch (Exception e) {
            return null;

I can see the out.println("return getconnection.") but the out.println after
that, in the method which calls the this method,  are not visible.

And for every sql statement I perform a lookup, get the connection, perform
the sql statement and then close the connection. Has anyone an idea what the
problem is?

Thanks in advance.

mfg Hans Sowa

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