Hi

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");
            System.out.println("lookup.");
            DataSource ds = (DataSource) envContext.lookup(resource);
            System.out.println("return getconnection.");
            return ds.getConnection();

        } catch (Exception e) {
            e.printStackTrace();
            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
mailto:[EMAIL PROTECTED]

Reply via email to