commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From St├ęphane RIFF <stephane.r...@cerene.fr>
Subject [DBCP] BindException
Date Wed, 02 Mar 2005 15:33:49 GMT
Hello
I've just implement DBCP pooling in a stand alone application on postgresql.
This work quite well but stiil have problems :
  Sometimes i got null connection from the datasource.

My datasource is setup like this :

DriverManager.setLogWriter(new PrintWriter(System.out));
try {
  Class.forName(dbd);
} catch (ClassNotFoundException e) {
    e.printStackTrace();
 }
GenericObjectPool connectionPool = new GenericObjectPool(null);
connectionPool.setMaxActive(10);
connectionPool.setMaxIdle(0);
ConnectionFactory connectionFactory = new 
DriverManagerConnectionFactory(dbc,dbu,dbp);
StackKeyedObjectPoolFactory stmPoolFactory = new 
StackKeyedObjectPoolFactory();
PoolableConnectionFactory poolableConnectionFactory = new 
PoolableConnectionFactory(connectionFactory,connectionPool,stmPoolFactory,null,false,false);
PoolingDataSource dataSource = new PoolingDataSource(connectionPool);
datasource = dataSource ;

My pool is in a singleton class, for getting a connection i did this
  ConnectionPool.getRef().getConnection() wich call datasource.getConnection

Here is the Stack trace, i got when
doing DriverManager.setLogWriter() :

DriverManager.getConnection("jdbc:postgresql://200.200.200.34:5432/geosiaradev") 

   trying 
driver[className=org.postgresql.Driver,org.postgresql.Driver@11ddcde]
org.postgresql.util.PSQLException
       at 
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:208)


       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:101) 

       at 
fr.cerene.geosiara.gprs.receiver.SQLoader.saveTrame2(SQLoader.java:210)
       at 
fr.cerene.geosiara.gprs.receiver.SQLoader$1.run(SQLoader.java:317)
       at java.lang.Thread.run(Thread.java:534)
getConnection failed: 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.<init>(Socket.java:309)
       at java.net.Socket.<init>(Socket.java:124)
       at org.postgresql.core.PGStream.<init>(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:101) 

       at 
fr.cerene.geosiara.gprs.receiver.SQLoader.saveTrame2(SQLoader.java:210)
       at 
fr.cerene.geosiara.gprs.receiver.SQLoader$1.run(SQLoader.java:317)
       at java.lang.Thread.run(Thread.java:534)
End of Stack Trace

java.lang.NullPointerException
       at 
fr.cerene.geosiara.gprs.receiver.SQLoader.saveTrame2(SQLoader.java:227)
       at 
fr.cerene.geosiara.gprs.receiver.SQLoader$1.run(SQLoader.java:317)
       at java.lang.Thread.run(Thread.java:534)

So i have two question :
  First does my pool configuration is good ?
  Second, does somebody already saw those exception and waht is the 
workaround ??

Thanks


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.7 - Release Date: 01/03/2005


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


Mime
View raw message