commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrián Cuartero <adriancuart...@yahoo.es>
Subject Re: [dbcp] Re: unexpected close
Date Thu, 15 May 2008 16:07:24 GMT
Hi

DBCP version is 1.2.2
driver version is 8.2-507

I'm running in axis2 without tomcat so i'm setting up the pool by my self.

Let me post the code

//Starts the pool
public Connector(){
        conf();
        bds = new BasicDataSource();
        bds.setDriverClassName("org.postgresql.Driver");
        bds.setUrl(url);
        bds.setUsername(user);
        bds.setPassword(pass);
        bds.setMaxActive(30);
    }
//return a connection
    public Connection getDBConnection(){
            try{
                return bds.getConnection();                
            }catch(SQLException e){
                e.printStackTrace();
                return null;                
            }
    }

//takes and closes the connection

            if(conn.isClosed()){
                conn = connector.getDBConnection();
            }


        }finally {
            if (pstmt != null) {
                try {
                    pstmt.close();
                } catch (Exception e) {}
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (Exception e) {    }
            }
        }

Thanks for your help

Adrián



What version of DBCP are you using and what version of the postgres driver?

Also, can you share the code that a) uses BasicDataSource (I assume
that is what you mean) to get the connection and b) closes it?

Are you running inside Tomcat or another app server or are you setting
up the pool yourself?  If the latter, are you closing the pool?

Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


      ______________________________________________ 
Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message