陈抒 

It is all explained on page 20 of the user guide:

        
http://svn.apache.org/repos/asf/ibatis/java/ibatis-3/trunk/doc/en/iBATIS-3-User-Guide.pdf

the relevant section is:

•       poolPingQuery – The Ping Query is sent to the database to validate that 
a connection is in good working order and is ready to accept requests. The 
default is "NO PING QUERY SET", which will cause most database drivers to fail 
with a decent error message.

•       poolPingEnabled – This enables or disables the ping query. If enabled, 
you must also set the poolPingQuery property with 
a valid SQL statement (preferably a very fast one). Default: false.

•       poolPingConnectionsNotUsedFor – This configures how often the 
poolPingQuery will be used. This can be set to match the typical timeout for a 
database connection, to avoid unnecessary pings. Default: 0 (i.e. all 
connections are pinged every time – but only if poolPingEnabled is true of 
course).


Basically, if poolPingConnectionsNotUsedFor = 0 then the ping query will be 
sent before every time the connection is used, and if 
poolPingConnectionsNotUsedFor > 0 then the ping query will be sent if the 
connection has been idle for at least that amount of time (you should set this 
to a smaller value than your timeout, which looks like it is set to 38000 
seconds or 10.5 hours).

Cheers

François

On May 12, 2010, at 8:18 AM, 陈抒 wrote:

> Hello:
> Thanks a lot!
> I am worrying about the overhead,because I don't know what iBatis3 will do 
> when I enable poolPingQuery.  
> I will try your idea soon.Thanks again!
> 
> 
> 陈抒 
> Best regards
> http://blog.csdn.net/sheismylife
> 
> 
> 2010/5/12 François Schiettecatte <fschietteca...@gmail.com>
> 陈抒
> 
> Not sure which RDBMS you are using. Ideally you want to set the idle 
> connection timeout in your pool to a value smaller than the idle connection 
> timeout on the server end, the errors you were seeing suggests that the 
> server has dropped the connection while the pool thinks it is still ok. From 
> my limited experience 'autoReconnect=true' is not recommended, here is an 
> excerpt from the MySQL documentation:
> 
> ----
> Should the driver try to re-establish stale and/or dead connections? If 
> enabled the driver will throw an exception for a queries issued on a stale or 
> dead connection, which belong to the current transaction, but will attempt 
> reconnect before the next query issued on the connection in a new 
> transaction. The use of this feature is not recommended, because it has side 
> effects related to session state and data consistency when applications don't 
> handle SQLExceptions properly, and is only designed to be used when you are 
> unable to configure your application to handle SQLExceptions resulting from 
> dead and stale connections properly. Alternatively, investigate setting the 
> MySQL server variable "wait_timeout" to some high value rather than the 
> default of 8 hours.
> ----
> 
> What you are doing will work but there is overhead associated with it, and 
> you might want use a query like 'select 1' rather than hitting the jobstatus 
> table. And you might want to read up on 'poolPingConnectionsNotUsedFor' on 
> page 20 of the documentation, the default value is 0 which means the 
> connection is pinged before every use.
> 
> I would recommend you check into these parameters to see if you can do away 
> with the ping query:
> 
>                <property name="poolMaximumActiveConnections" value="10" />
>                <property name="poolMaximumIdleConnections" value="5" />
>                <property name="poolMaximumCheckoutTime" value="20000" />
>                <property name="poolTimeToWait" value="20000" />
> 
> Cheers
> 
> François
> 
> On May 12, 2010, at 6:57 AM, 陈抒 wrote:
> 
> > I don't know.
> > But I took one hour to test my application again,it works fine if the 'time 
> > out' problem doesn't occurs.
> > Now I add two properties,let's wait and see if it can solve this or not.
> > <property name="poolPingQuery" value="select * from jobstatus"/>
> > <property name="poolPingEnabled" value="true"/>
> >
> > 陈抒
> > Best regards
> > http://blog.csdn.net/sheismylife
> >
> >
> > On Wed, May 12, 2010 at 6:46 PM, Martin Ellis <mar...@ellis.name> wrote:
> > On 12 May 2010 02:31, 陈抒 <csfreeb...@gmail.com> wrote:
> > > Caused by: java.lang.NullPointerException
> > >         at freebird.business.Email.getReceiverList(Email.java:105)
> >
> > What caused this NullPointerException?
> > Is it really related to the connection option?
> >
> > Martin
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
> > For additional commands, e-mail: user-java-h...@ibatis.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
> For additional commands, e-mail: user-java-h...@ibatis.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org

Reply via email to