You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Matthew Hixson <hi...@poindextrose.org> on 2009/04/20 07:09:14 UTC

[dbcp] java.io.EOFException, underlying cause: null

Occasionally I'll see this exception in our logs.  I have setup the  
pool like so:

GenericObjectPool pool = new GenericObjectPool(null);
pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
pool.setTestOnBorrow(true);
pool.setTestOnReturn(true);
pool.setTestWhileIdle(true);

Is that not sufficient to have DBCP test a connection before releasing  
it from the pool for use?
   Thanks,
     -M@


-------------------------------------------
java.sql.SQLException: Communication link failure:  
java.io.EOFException, underlying cause: null

** BEGIN NESTED EXCEPTION **

java.io.EOFException

STACKTRACE:

java.io.EOFException
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1395)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1539)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1930)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
	at  
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java: 
1634)
	at  
org 
.apache 
.commons 
.dbcp 
.DelegatingPreparedStatement 
.executeQuery(DelegatingPreparedStatement.java:93)
...

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


Re: [dbcp] java.io.EOFException, underlying cause: null

Posted by Phil Steitz <ph...@gmail.com>.
Matthew Hixson wrote:
> Hi Mark, I'm just using GenericObjectPool and it does not have a 
> setValidationQuery() method.  Do I need to use a more specific object 
> pool class or did you mean that setValidationQuery needs to be called 
> on something else?  My method now looks like:
>
> GenericObjectPool pool = new GenericObjectPool(null);
> pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
> pool.setTestOnBorrow(true);
> pool.setTestOnReturn(true);
> pool.setTimeBetweenEvictionRunsMillis(10000);
> pool.setTestWhileIdle(true);
> ConnectionFactory connectionFactory = new 
> DriverManagerConnectionFactory(jdbcUrl),null);
> new 
> PoolableConnectionFactory(connectionFactory,pool,null,null,false,true);
Replace the second null in the PoolableConnectionFactory constructor 
above with an SQL string representing the validation query.  The 
validation query needs to return at least on row for validation to 
succeed.  Supplying null to the validationQuery parameter in the 
connection factory constructor turns off validation, regardless of the 
pool setting. 

Phil
> return(new PoolingDataSource(pool));
>
>   Thanks,
>    -M@
>
> On Apr 20, 2009, at 1:28 AM, Mark Thomas wrote:
>
>> Matthew Hixson wrote:
>>> Occasionally I'll see this exception in our logs.  I have setup the 
>>> pool
>>> like so:
>>>
>>> GenericObjectPool pool = new GenericObjectPool(null);
>>> pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
>>> pool.setTestOnBorrow(true);
>>> pool.setTestOnReturn(true);
>>> pool.setTestWhileIdle(true);
>>>
>>> Is that not sufficient to have DBCP test a connection before releasing
>>> it from the pool for use?
>>
>> No. You need to call set the validation query too. E.g.:
>>
>> pool.setValidationQuery("SELECT 1");
>>
>> HTH,
>>
>> Mark
>>
>>>  Thanks,
>>>    -M@
>>>
>>>
>>> -------------------------------------------
>>> java.sql.SQLException: Communication link failure: 
>>> java.io.EOFException,
>>> underlying cause: null
>>>
>>> ** BEGIN NESTED EXCEPTION **
>>>
>>> java.io.EOFException
>>>
>>> STACKTRACE:
>>>
>>> java.io.EOFException
>>>    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1395)
>>>    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1539)
>>>    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1930)
>>>    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
>>>    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
>>>    at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
>>>    at
>>> com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1634) 
>>>
>>>    at
>>> org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) 
>>>
>>>
>>> ...
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


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


Re: [dbcp] java.io.EOFException, underlying cause: null

Posted by Matthew Hixson <hi...@poindextrose.org>.
Hi Mark, I'm just using GenericObjectPool and it does not have a  
setValidationQuery() method.  Do I need to use a more specific object  
pool class or did you mean that setValidationQuery needs to be called  
on something else?  My method now looks like:

GenericObjectPool pool = new GenericObjectPool(null);
pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
pool.setTestOnBorrow(true);
pool.setTestOnReturn(true);
pool.setTimeBetweenEvictionRunsMillis(10000);
pool.setTestWhileIdle(true);
ConnectionFactory connectionFactory = new  
DriverManagerConnectionFactory(jdbcUrl),null);
new  
PoolableConnectionFactory(connectionFactory,pool,null,null,false,true);
return(new PoolingDataSource(pool));

   Thanks,
    -M@

On Apr 20, 2009, at 1:28 AM, Mark Thomas wrote:

> Matthew Hixson wrote:
>> Occasionally I'll see this exception in our logs.  I have setup the  
>> pool
>> like so:
>>
>> GenericObjectPool pool = new GenericObjectPool(null);
>> pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
>> pool.setTestOnBorrow(true);
>> pool.setTestOnReturn(true);
>> pool.setTestWhileIdle(true);
>>
>> Is that not sufficient to have DBCP test a connection before  
>> releasing
>> it from the pool for use?
>
> No. You need to call set the validation query too. E.g.:
>
> pool.setValidationQuery("SELECT 1");
>
> HTH,
>
> Mark
>
>>  Thanks,
>>    -M@
>>
>>
>> -------------------------------------------
>> java.sql.SQLException: Communication link failure:  
>> java.io.EOFException,
>> underlying cause: null
>>
>> ** BEGIN NESTED EXCEPTION **
>>
>> java.io.EOFException
>>
>> STACKTRACE:
>>
>> java.io.EOFException
>>    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1395)
>>    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1539)
>>    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1930)
>>    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
>>    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
>>    at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
>>    at
>> com 
>> .mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java: 
>> 1634)
>>    at
>> org 
>> .apache 
>> .commons 
>> .dbcp 
>> .DelegatingPreparedStatement 
>> .executeQuery(DelegatingPreparedStatement.java:93)
>>
>> ...
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


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


Re: [dbcp] java.io.EOFException, underlying cause: null

Posted by Mark Thomas <ma...@apache.org>.
Matthew Hixson wrote:
> Occasionally I'll see this exception in our logs.  I have setup the pool
> like so:
> 
> GenericObjectPool pool = new GenericObjectPool(null);
> pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
> pool.setTestOnBorrow(true);
> pool.setTestOnReturn(true);
> pool.setTestWhileIdle(true);
> 
> Is that not sufficient to have DBCP test a connection before releasing
> it from the pool for use?

No. You need to call set the validation query too. E.g.:

pool.setValidationQuery("SELECT 1");

HTH,

Mark

>   Thanks,
>     -M@
> 
> 
> -------------------------------------------
> java.sql.SQLException: Communication link failure: java.io.EOFException,
> underlying cause: null
> 
> ** BEGIN NESTED EXCEPTION **
> 
> java.io.EOFException
> 
> STACKTRACE:
> 
> java.io.EOFException
>     at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1395)
>     at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1539)
>     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1930)
>     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
>     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
>     at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
>     at
> com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1634)
>     at
> org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
> 
> ...
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 



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