I had this general question : can a connection pool keep in cache some "ancient" connection and serve it while an other one is called ? I know it somehow does, but does it use connection objects already created via some DataSource while I explicitly changed the lookup into that Datasource to a new JNDI adresse and, with this new lookup, created a new connection (which I was hoping to use, that is) ?

To be a bit specific, here were my steps :

I've created a connection in my GlassFish server, given it a name in the JNDI, used that in my code as follows :

InitialContext ctx = new InitialContext();
         //The JDBC Data source that we just created
        DataSource ds = (DataSource) ctx.lookup("postgresJNDI");
        Connection connection = ds.getConnection();
        Statement st = connection.createStatement();

        ResultSet rs = st.executeQuery("SELECT util_firm, util_name, previlege FROM utilisateur WHERE password = '" + password + "' AND pseudo = '" + pseudo + "' ") ;

problem is once the request is send I get back an alert stating that :

serverError: class javax.faces.el.EvaluationException the name of column utilfirm was not found in this ResultSet.

And utilfirm is not even in my request, neither is it on my database for that matter (but was on an ancient one I've erased, one that was accessed via an other JNDI addresse...).

I might add that I've taken care of closing every connection I used.

So is this normal ? Or is it something in my configuration ?

Thanks in advance.

有帮助吗?

解决方案

So as was expecting, the bean in which the connection pooling was used did in fact (for some mysterious reason) hold the name of some old JNDI, therefore not taking into account the new one specified in the code. And thus, I just went ahead and created a new bean and used it instead, now all is working fine.

I am still interested in any documentation related to the subject.

Have a nice day/night all !

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top