You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Armin Waibel <ar...@apache.org> on 2004/03/12 14:21:50 UTC

Re: Until now: Problem with database connection

Hi again Hinnerk,

Hinnerk Feldwisch wrote:
> Hello altogether!,
> 
> a month ago I posted a question regarding problems with the database
> connection of my JSP- application; after some hours (don't know exactly,
> perhabs 12h) the connection is killed, probably by the database server
> (MySQL).


hmm, how this could be? You are using a ConnectionFactory that does not 
pool connections.
Do you hold PB instances in your code? Normally the actual thread obtain 
a PB instance  from the PBF do his work and close the PB instance after 
use immediately.
If you don't do so, it is possible that the PB instance keep the used 
connection open after a read operation. The used connection will be 
closed when PB.close(), PB.commitTransaction(), PB.abortTransaction() 
was called (or you can release the connection using the 
ConnectionManager - not recommended).

regards,
Armin


> Armin Waibel was so kind to help me with this proposals:
> 
> On Thu, 12 Feb 2004 14:25:48 +0100 Armin Waibel wrote:
> 
>>Seems that the connections in the connection-pool (assume you don't use 
>>DataSource) are get timed out.
>>
>>- Some DB allow to reconnect timed out connections, try to enable this. 
>>- Or you can use the 'validationQuery' attribute to force OJB to do a 
>>real check before a connection was returned from pool.
>>- Or don't use a connection pool by setting
>>ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl
>>(has performance impact).
>>- Or setup pool configuration to evict idle connections before they get 
>>timed out. commons-pool attributes reflected as 'connection-pool' 
>>attributes. See more
>>http://db.apache.org/ojb/repository.html#connection-pool
>>http://jakarta.apache.org/commons/pool/apidocs/org/apache/commons/pool/impl/GenericKeyedObjectPool.html
>>- Or use DataSource from your webServer (and hope your webserver does 
>>handle timed out connections for you ;-))
>>- Or write your own ConnectionFactory implementation ;-)
> 
> 
> I tried several of them, but had now luck :( Does anyone have any further
> idea? That would be great!
> 
> I have set the ConnectionFactoryClass to
> "org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl" in my
> ojb.properties, and down under follows my repository_database.xml.
> 
> Thank you quite much,
> Hinnerk
> 
> 
>     <!-- this connection was used as the default one within OJB -->
>     <jdbc-connection-descriptor
>         jcd-alias="*****"
>    	    default-connection="true"
>         platform="MySQL"
>         jdbc-level="2.0"
>         driver="org.gjt.mm.mysql.Driver"
>         protocol="jdbc"
>         subprotocol="mysql"
>         dbalias="****"
>         username="*****"
>         password="**"
>         eager-release="false"
>    	    batch-mode="false"
>         useAutoCommit="1"
>         ignoreAutoCommitExceptions="false"
>      >
> 
>         <connection-pool
>         maxActive="10"
>         maxIdle="5"
>          maxWait="6000"
>          minEvictableIdleTimeMillis="6000"
>          numTestsPerEvictionRun="5"
>          timeBetweenEvictionRunsMillis="60000"
>          whenExhaustedAction="2"
>          validationQuery="select count(*) from users" />
> 
>         <sequence-manager>
> className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
>             <attribute attribute-name="grabSize" attribute-value="20"/>
>             <attribute attribute-name="autoNaming" attribute-value="true"/>
>             <attribute attribute-name="globalSequenceId"  
>                  attribute-value="false"/>
>             <attribute attribute-name="globalSequenceStart" 
>                  attribute-value="10000"/>
>         </sequence-manager>
>    </jdbc-connection-descriptor>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

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