X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 90DBC56683 for ; Tue, 1 Mar 2005 13:13:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44019-01 for ; Tue, 1 Mar 2005 13:13:30 +0000 (GMT) Received: from relay.imatech.net (relay.imatech.net [81.255.215.226]) by svr1.postgresql.org (Postfix) with ESMTP id 065EC56528 for ; Tue, 1 Mar 2005 13:13:27 +0000 (GMT) Received: from pop.imatech.net (81.255.215.227) by relay.imatech.net with MERCUR Mailserver (v4.03.06 MTI0LTIzMDYtNjkyMw==) for ; Tue, 1 Mar 2005 14:12:04 +0100 Received: from imatech.net (81.255.215.226) by pop.imatech.net with MERCUR Mailserver (v4.03.13 ODUtMjQzNS00ODc3) for ; Tue, 1 Mar 2005 14:12:15 +0100 Received: from [200.200.200.185] ([195.6.193.141]) by imatech.net with Microsoft SMTPSVC(6.0.3790.211); Tue, 1 Mar 2005 14:11:57 +0100 Received: from 127.0.0.1 (AVG SMTP 7.0.300 [266.5.2]); Tue, 01 Mar 2005 14:12:15 +0100 Message-ID: <42246A2E.60604@cerene.fr> Date: Tue, 01 Mar 2005 14:12:14 +0100 From: =?ISO-8859-1?Q?St=E9phane_RIFF?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en To: Oliver Jowett Cc: pgsql-jdbc@postgresql.org Subject: Re: Connection pool problem References: <42242041.8030604@cerene.fr> <422456E7.8060303@opencloud.com> In-Reply-To: <422456E7.8060303@opencloud.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-OriginalArrivalTime: 01 Mar 2005 13:11:57.0583 (UTC) FILETIME=[3F3181F0:01C51E60] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.11 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/8 X-Sequence-Number: 12401 You're right i forgot to call close() function in the catch block Thanks But know i sometimes get null connections from the datasource with exception like this : 2005-03-01 12:23:44,156 : [WARN] ConnectionPool - org.postgresql.util.PSQLException: The connection attempt failed because Exception: java.net.BindException: Address already in use: connect Stack Trace: java.net.BindException: Address already in use: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158) at java.net.Socket.connect(Socket.java:452) at java.net.Socket.connect(Socket.java:402) at java.net.Socket.(Socket.java:309) at java.net.Socket.(Socket.java:124) at org.postgresql.core.PGStream.(PGStream.java:47) at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:197) at org.postgresql.Driver.connect(Driver.java:139) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:48) at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290) at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:771) at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95) at fr.cerene.geosiara.gprs.receiver.ConnectionPool.getConnection(ConnectionPool.java:97) at fr.cerene.geosiara.gprs.receiver.SQLoader.saveTrame(SQLoader.java:122) at fr.cerene.geosiara.gprs.receiver.SQLoader$1.run(SQLoader.java:219) at java.lang.Thread.run(Thread.java:534) End of Stack Trace 2005-03-01 12:23:44,156 : [WARN] SQLoader - java.lang.NullPointerException I saw on the web that this can happened when the max number of connection is reach but in my case postgresql is configure with 100 connections, in the process list i had ~50 connections. Don't know what i can do... Oliver Jowett wrote: > Stéphane RIFF wrote: > >> I've create a connection pool with dbcp end another with >> Jdbc3PoolingDatasource, >> it seems to work well but : >> My pool is a eight connections pool, the problem is when i get some >> database exception (for example >> "constraint violation", "duplicate key on unique index"...) the >> connection didn't released to the pool. >> After eight exception my application wait for a connection from the >> pool which nerver give one because >> of the PSQLException thrown. > > > Perhaps your code does not release the connection to the pool > correctly when handling the exception? > > The usual way to deal with this is to put connection releasing in a > finally block, so it's sure to be run however you exit the try{} block. > > If it's not that, I'd need to see your code to debug this further. > > -O > > -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.5.2 - Release Date: 28/02/2005