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 Hinnerk Feldwisch <us...@hinnerkf.de> on 2004/02/12 13:38:01 UTC

Problem with database connection

Hello altogether,

I developed a jsp/struts/ojb- project which runs fine on my private server;
but after approximately two days the database connection fails on the real
server where the website shall be accessible.
At the end I will post the error- message.

For me the problem seams to be that there's some connection error on the
server (I don't know why), and OJB doesn't try to establish a new JDBC-
Connection; is this right? Is there any way to do so?

All other projects on this internet server do run fine - but they don't use
OJB.

Would be glad for any hint!,
thanks,
Hinnerk

-------
javax.servlet.jsp.JspException: Exception accessing property
latestNews[0].daughtersSize
for bean messageManager:
org.apache.ojb.broker.PersistenceBrokerSQLException:
Communication link failure: java.net.SocketException
at
org.apache.struts.taglib.logic.CompareTagBase.condition(CompareTagBase.java:233)
at org.apache.struts.taglib.logic.EqualTag.condition(EqualTag.java:90)
at
org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(ConditionalTagBase.java:218)
at
org.apache.struts.taglib.nested.logic.NestedEqualTag.doStartTag(NestedEqualTag.java:96)
at
_WEB_22dINF._jsp._viewshortnews__jsp._jspService(/WEB-INF/jsp/viewshortnews.jsp:38)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:485)
(...)


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


Re: Problem with database connection

Posted by Hinnerk Feldwisch <us...@hinnerkf.de>.
Thank you for your answers, Brendan and Armin!

I'm trying the minEvictableIdleTimeMillis now, set it to 60000 - should
that be fine?

Have a good weekend,
Hinnerk


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


Re: Until now: Problem with database connection

Posted by Armin Waibel <ar...@apache.org>.
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


Until now: Problem with database connection (was: Problem with database connection)

Posted by Hinnerk Feldwisch <us...@hinnerkf.de>.
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). 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


Re: Problem with database connection

Posted by Armin Waibel <ar...@apache.org>.
Hi,

Hinnerk Feldwisch wrote:

> Hello altogether,
> 
> I developed a jsp/struts/ojb- project which runs fine on my private server;
> but after approximately two days the database connection fails on the real
> server where the website shall be accessible.
> At the end I will post the error- message.

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 ;-)

You see OJB is flexible ;-)

regards,
Armin

> 
> For me the problem seams to be that there's some connection error on the
> server (I don't know why), and OJB doesn't try to establish a new JDBC-
> Connection; is this right? Is there any way to do so?
> 
> All other projects on this internet server do run fine - but they don't use
> OJB.
> 
> Would be glad for any hint!,
> thanks,
> Hinnerk
> 
> -------
> javax.servlet.jsp.JspException: Exception accessing property
> latestNews[0].daughtersSize
> for bean messageManager:
> org.apache.ojb.broker.PersistenceBrokerSQLException:
> Communication link failure: java.net.SocketException
> at
> org.apache.struts.taglib.logic.CompareTagBase.condition(CompareTagBase.java:233)
> at org.apache.struts.taglib.logic.EqualTag.condition(EqualTag.java:90)
> at
> org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(ConditionalTagBase.java:218)
> at
> org.apache.struts.taglib.nested.logic.NestedEqualTag.doStartTag(NestedEqualTag.java:96)
> at
> _WEB_22dINF._jsp._viewshortnews__jsp._jspService(/WEB-INF/jsp/viewshortnews.jsp:38)
> at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
> at com.caucho.jsp.Page.subservice(Page.java:485)
> (...)
> 
> 
> ---------------------------------------------------------------------
> 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