unexpected close

View: New views
4 Messages — Rating Filter:   Alert me  

unexpected close

by Adrián Cuartero :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all

I have a web service connected to postgresql. If i use the connections to the database and close them normaly i don't have any problem, but now i'm trying to use BasicDataBase class to pool the connections but when i close a connection to return it to the pool the postgresql log show this message :"unexpected EOF on client connection".

What can i do to solve this problem?
Thanks



      ______________________________________________
Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.

[dbcp] Re: unexpected close

by Phil Steitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, May 14, 2008 at 1:34 PM, Adrián Cuartero
<adriancuartero@...> wrote:
> Hi all
>
> I have a web service connected to postgresql. If i use the connections to the database and close them normaly i don't have any problem, but now i'm trying to use BasicDataBase class to pool the connections but when i close a connection to return it to the pool the postgresql log show this message :"unexpected EOF on client connection".
>
> What can i do to solve this problem?

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@...
For additional commands, e-mail: user-help@...


Parent Message unknown Re: [dbcp] Re: unexpected close

by Adrián Cuartero :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
For additional commands, e-mail: user-help@...


      ______________________________________________
Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.

Re: [dbcp] Re: unexpected close

by Phil Steitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are you sure the errors are being reported for each connection close,
or are they just being reported when the app shuts down?  If the
latter, issueing bds.close() as part of application shutdown should
address the problem.   BasicDataSource does not close physical
connections when they are returned to the pool, so if your app never
invokes close on the BasicDataSource itself, the connections will be
abandoned on the client (DBCP) side when the app shuts down.  This
does not cause postgres to leak connections, since the client is
dropping the connection, but you see the message in the logs
indicating that a connection has been dropped.  To get rid of the
error message, you need to get DBCP to close the underlying physical
connections.  BasicDataSource's close method does that.

Phil

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