users@glassfish.java.net

Problem closing Glassfish JDBC connection (from pool)

From: HAcland <hughacland_at_googlemail.com>
Date: Thu, 17 Jan 2008 01:06:51 -0800 (PST)

Hi,

[code] DataSource db = DBCon.getDBCon();[/code]
....
[code]
public class DBCon {

    public static DataSource getDBCon() {
        try {
           DataSource myDB = DBCon.getPWA();
           return myDB;
       } catch (NamingException ex) {
           Logger.getLogger(DBCon.class.getName()).log(Level.SEVERE, null,
ex);
           return null;
       }
   }

    private static DataSource getPWA() throws NamingException {
        Context c = new InitialContext();
        return (DataSource) c.lookup("java:comp/env/PWA");
    }
     
}[/code]

The problem I am having is that even when I call [code]
db.getConnection().close();[/code]
it doesn't appear to close the connection because after a while i get an
error message from glassfish saying "Connection could not be allocated
because: Data source rejected establishment of connection, message from
server: "Too many connections"

Is there a better way to close the connections Or am I just not doing it
correctly.

Thanks
     
       
-- 
View this message in context: http://www.nabble.com/Problem-closing-Glassfish-JDBC-connection-%28from-pool%29-tp14914892p14914892.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.