<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MySQL Preacher &#187; connector</title>
	<atom:link href="http://mysqlpreacher.com/wordpress/tag/connector/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysqlpreacher.com/wordpress</link>
	<description>Because Sharing is Caring</description>
	<lastBuildDate>Sat, 14 Apr 2012 17:45:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>mysql jdbc connector autoReconnect=true</title>
		<link>http://mysqlpreacher.com/wordpress/2010/06/mysql-jdbc-connector-autoreconnecttrue/</link>
		<comments>http://mysqlpreacher.com/wordpress/2010/06/mysql-jdbc-connector-autoreconnecttrue/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:13:15 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[autoreconnect]]></category>
		<category><![CDATA[connector]]></category>
		<category><![CDATA[ibatis]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[keepalive]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[wait_timeout]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=356</guid>
		<description><![CDATA[What makes you think jdbc autoreconnect is needed? Application is idle for long periods at a time? Wait_timeout too short? Network failure or glitches? Some good suggestions form Mark Matthews - Bug #5020 Having encountered the problem again myself today, trying to make jdbc for mysql reconnect any terminated connections using autoreconnect=true I figured out [...]]]></description>
			<content:encoded><![CDATA[<p>What makes you think jdbc autoreconnect is needed?<br />
Application is idle for long periods at a time?<br />
Wait_timeout too short?<br />
Network failure or glitches?</p>
<p>Some good suggestions form Mark Matthews -<a href="http://bugs.mysql.com/bug.php?id=5020" target="_blank"> Bug #5020</a></p>
<p>Having encountered the problem again myself today, trying to make jdbc for mysql reconnect any terminated connections using autoreconnect=true I figured out a way to work it out from the pooling side.<br />
<br /><br />
Introduction to the problem:</p>
<p>On the mysql side wait_timeout is set to default 8hrs and any connections idle for longer than that were beomg terminated despite setting the connection string to: url=jdbc:mysql://localhost:3306/dbname?autoReconnect=true. The application was thence throwing an exception.</p>
<p>The solution was to introduce a ping from the pooler which for &#8220;Ibatis&#8221;, the pooler technology used in this case, was:</p>
<p>This covers eventualities of network glitches or connections exceeding the wait_timeout having the pooler ping the database if the connection was idle for more than 10 seconds (the value is in milliseconds).</p>
<p>The configuration if Ibatis in this case is something like:</p>
<p>Ibatis<code><br />
</code></p>
<p><code></p>
<div id="_mcePaste">&lt;transactionManager type="JDBC"&gt;</div>
<div id="_mcePaste">&lt;dataSource type="SIMPLE"&gt;</div>
<div id="_mcePaste">&lt;property value="${driver}" name="JDBC.Driver"/&gt;</div>
<div id="_mcePaste">&lt;property value="${url}" name="JDBC.ConnectionURL"/&gt;</div>
<div id="_mcePaste">&lt;property value="${username}" name="JDBC.Username"/&gt;</div>
<div id="_mcePaste">&lt;property value="${password}" name="JDBC.Password"/&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingQuery" value="select 1"/&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingEnabled" value="true"/&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingConnectionsOlderThan" value="3600000"/&gt; &lt;!-- 1 hr --&gt;</div>
<div id="_mcePaste">&lt;property name="Pool.PingConnectionsNotUsedFor" value="10000"/&gt; &lt;!-- ping db 10 sec --&gt;</div>
<div id="_mcePaste">&lt;/dataSource&gt;</div>
<div id="_mcePaste">&lt;/transactionManager&gt;</div>
<div></div>
<p></code><br />
<br /><br /><br />
For every pooling technology there will be a different &#8220;Pool.PingConnectionsNotUsedFor&#8221; term, but the concept is still there. It worked like a charm.<br />
<br /><br /><br />
<code><br />
JDBC driver=com.mysql.jdbc.Driver<br />
url=jdbc:mysql://localhost:3306/dbname<br />
username=username<br />
password=password</code><br />
<br /><br /><br />
PS &#8230; autoreconnect is not recommended when using mysql jdbc!</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2010/06/mysql-jdbc-connector-autoreconnecttrue/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

