<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "restoring db connection"]]></title>
		<link>http://forums.visual-paradigm.com/posts/32.html</link>
		<description><![CDATA[Latest messages posted in the topic "restoring db connection"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>restoring db connection</title>
				<description><![CDATA[ Hi, I am using the ORM library generated by VP.<br> An object is inserted into the db, let's say once in few seconds by the Timer.<br> If some problem occurs with network connection to the database and an Exception if thrown, after the restoring of the network connection, anyway nothing can be saved, because getInstace() member is returning _instace with a connection which is no longer valid, and it does not go further until application (it is a service in my case) restart.<br> What I have done wrong, how can I bypass this? I could not find anything like this on the forum.<br> Thank you. ik]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2641#20103.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2641#20103.html</link>
				<pubDate><![CDATA[Sat, 10 Nov 2007 01:29:41]]></pubDate>
				<author><![CDATA[ ik]]></author>
			</item>
			<item>
				<title>Re:restoring db connection</title>
				<description><![CDATA[ Hi ik,<br> <br> We are now discussing your case. Will get back to you once we've came up and conclusion.<br> <br> Best regards,<br> Jick<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2641#20151.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2641#20151.html</link>
				<pubDate><![CDATA[Tue, 13 Nov 2007 15:53:13]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>Re:restoring db connection</title>
				<description><![CDATA[ Thanks, may be additional information is needed?<br> The problem was discovered in logs, after a night without any activity, mysql probably closed the connection, and on next try to save, an exception is thrown. But probably I did something wrong...  :roll: ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2641#20162.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2641#20162.html</link>
				<pubDate><![CDATA[Wed, 14 Nov 2007 09:27:53]]></pubDate>
				<author><![CDATA[ ik]]></author>
			</item>
			<item>
				<title>Re:restoring db connection</title>
				<description><![CDATA[ Hi iK,<br> <br> Sorry, but we were unable to reproduce the problem. In our testing, the connection pool will throw exception if connection lost, but it can recover itself when connection repaired.<br> <br> In fact, the next call for getSession() will return a valid connection. I guess your main problem is that the connection idle has been too long. This can be fixed by setting timeout in connection pool, after the specified time, it'll renew the connection.<br> <br> Best regards,<br> Jick<br> ]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2641#20194.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2641#20194.html</link>
				<pubDate><![CDATA[Thu, 15 Nov 2007 19:04:47]]></pubDate>
				<author><![CDATA[ Jick]]></author>
			</item>
			<item>
				<title>restoring db connection</title>
				<description><![CDATA[ <table class="quote-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>ik wrote:</b></span></td>
		</tr>
		</table>
		
		<table class="quote-table" align="center">
		<tr>
		<td class="quote">Hi, I am using the ORM library generated by VP.<br> An object is inserted into the db, let's say once in few seconds by the Timer.<br> If some problem occurs with network connection to the database and an Exception if thrown, after the restoring of the network connection, anyway nothing can be saved, because getInstace() member is returning _instace with a connection which is no longer valid, and it does not go further until application (it is a service in my case) restart.<br> What I have done wrong, how can I bypass this? I could not find anything like this on the forum.<br> Thank you. ik&nbsp;
		</td>
		</tr>
		</table><br> <br> Hi Ik,<br> <br> I think I was experiencing this same problem you have. My code was aprox:<br> <br>  <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre> 
 // C# code:
 while &#40;true&#41; {
     PersistentSession s=Manager.Instance&#40;&#41;.GetSession&#40;&#41;;
     PersistentTransaction t=s.BeginTransaction&#40;&#41;;
 
     try {
         // Some method calls using persistence
         t.Commit&#40;&#41;;
     }
     catch {
         // Some error
         t.RollBack&#40;&#41;;
     }
 }
  </pre></td>
		</tr>
		</table> <br> <br> Well... this went all ok except when an exception was thrown  :evil: But... all I had to do to fix this was:<br> - add "s.Close()" in the catch<br> <br> So the final code was:<br>  <table class="code-table-simple" align="center">
		<tr> 
		<td><span class="genmed"><b>Code:</b></span></td>
		</tr>
		</table>
		<table class="code-table" align="center">
		<tr>
		<td class="code">
		<pre> 
 // C# code:
 while &#40;true&#41; {
     PersistentSession s=Manager.Instance&#40;&#41;.GetSession&#40;&#41;;
     PersistentTransaction t=s.BeginTransaction&#40;&#41;;
 
     try {
         // Some method calls using persistence
         t.Commit&#40;&#41;;
     }
     catch {
         // Some error
         t.RollBack&#40;&#41;;
         s.Close&#40;&#41;;    // &lt;------------------- NEW
     }
 }
  </pre></td>
		</tr>
		</table> <br> <br> Then, this time the .GetSession() at the top of the while was returning a valid connection, session, etc.<br> <br> BTW, this sample code was written without compiling it. Please excuse some syntax errors, you get the idea  :roll: <br> <br> Maybe this helps you.<br> <br> Best regards]]></description>
				<guid isPermaLink="true">http://forums.visual-paradigm.com/posts/2641#20221.html</guid>
				<link>http://forums.visual-paradigm.com/posts/2641#20221.html</link>
				<pubDate><![CDATA[Fri, 16 Nov 2007 16:11:50]]></pubDate>
				<author><![CDATA[ distansia]]></author>
			</item>
	</channel>
</rss>