<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Connecting to a DB....([BEA][SQLServer JDBC Driver]No more data available to read.)"]]></title>
		<link>http://forums.hotjoe.com/posts/list/9.page</link>
		<description><![CDATA[Latest messages posted in the topic "Connecting to a DB....([BEA][SQLServer JDBC Driver]No more data available to read.)"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Connecting to a DB....([BEA][SQLServer JDBC Driver]No more data available to read.)</title>
				<description><![CDATA[ <br /> [BEA][SQLServer JDBC Driver]No more data available to read. is the latest and greatest JDBC error I’ve gotten. I've posted some other threads on database related question in the past and I'm kind of at a junction where having a mentor at work would come in handy because i have a knack for finding connection handling (or lack there of) issues. <br /> <br /> For the most part on the handful of apps I’ve built I use the following pattern to handle connections. As i progress through my apps and I mature as a developer it gets slightly more sophisticated, but here goes. <br /> This code won't compile and obviously isn't complete (I’ll try and come up with a working example here in the next day or so)<br /> <br /> [code]<br /> public class DatabaseConnections <br /> {<br /> 	public static Connection getConnection(String JNDIName)<br /> 	{<br /> 		//get connection don't remember how this is done, I'll have to check it out<br /> 		//when I'm at work if it's relevant, which i don't think it is. <br /> 	}<br /> 	<br /> 	public static void closeConnections(String debugging, Connection conn, Statement statement, ResultSet resultSet)<br /> 	{<br /> 		//use "debugging" for my logging. <br /> 		try{<br /> 			if(conn!=null)<br /> 				conn.close()<br /> 		}<br /> 		catch (SQLException e){<br /> 			//report exception<br /> 		}<br /> 		conn=null;<br /> 		try{<br /> 			if(statement!=null)<br /> 				statement.close();<br /> 		}<br /> 		catch (SQLException e)		{<br /> 			//report exception <br /> 		}<br /> 		statement=null;<br /> 		try{<br /> 			if(resultSet!=null)<br /> 				resultSet.close();<br /> 		}<br /> 		catch (SQLException e)	{<br /> 			//report exception<br /> 		}<br /> 		resultSet=null;<br /> 	}<br /> }<br /> [/code]<br /> <br /> Then in where ever i actually need a connection i do the following: <br /> <br /> [code]<br /> public class SomeQuery <br /> {<br /> 	<br /> 	public void pingDB()<br /> 	{<br /> 		Connection connPing=null;<br /> 		PreparedStatement pStatementPing=null;<br /> 		ResultSet resultSetPing =null;<br /> 		try<br /> 		{<br /> 			connPing= DatabaseConnections.getConnection("MY_POOL");<br /> 			pStatementPing = connPing.prepareStatement("SELECT * FROM DATA");<br /> 			//bind variables if needed<br /> 			resultSetPing = pStatementPing.executeQuery();	<br /> 			<br /> 			//do what you gotta do with resultSet<br /> 		}<br /> 		catch (SQLException e)<br /> 		{<br /> 			//do whatever<br /> 		}<br /> 		catch(Exception e)<br /> 		{<br /> 			//do whatever<br /> 		}<br /> 		finally<br /> 		{<br /> 			DatabaseConnections.closeConnections("pingDB", connPing, pStatementPing, resultSetPing);<br /> 		}<br /> 	}<br /> }<br /> [/code]<br /> <br /> I'm in a j2ee environment so threading could be/is an issue here. Am I closing all my connections here? <br /> Here's my understanding of what's going on. <br /> connPing, pStatementPing & resultSetPing are created and stuff is done with them. Then a pass a copy of their reference to closeConnections(). <br /> Close closes the 3 objects, but the null assignment only affects conn, pStatement, & resultSet. When closeConnections() finishes running we go back to the of the finally and ultimatly out of pingDB()  <br /> I don't need to assign null to connPing pStatementPing, and resultSetPing since they drop out of scope (after being closed in closeConnections()) after the finally anyways. <br /> <br /> So that's my understanding of what's going on. Assuming that the above is true and that I haven't confused myself (or anyone reading this ;) ) I'm fairly confident that I'm handling my connections properly. <br /> <br /> So now for this [url=http://www.weblogic.com/docs45/techsupport/faq/jdbckona_mssqlserver.html]SQLException[/url]...I'm kinda clueless. I did the ol google and read a bunch of them and it seems like one of those fun errors that a decent amount of folks get and no one really knows what to do about it. The most popular answer is that the [url=http://forum.java.sun.com/thread.jspa?threadID=510477&messageID=2464074]connections aren't being handled properly.[/url]  I also saw a hit about weblogic being not being configured properly, and then finally someone [url=http://www.mcse.ms/archive90-2004-12-1285118.html]thought it was a threading issue.[/url]<br /> <br /> So i guess all this confusing inner dialog boils down to 2 questions. <br /> Is using static methods in a different class to get & close connections okay in terms of proper connection management? <br /> <br /> The second question would be any thoughts or solutions on this SQLException I'm getting.<br /> ]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/296/1252.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/296/1252.page</link>
				<pubDate><![CDATA[Tue, 20 Jun 2006 19:16:03]]> GMT</pubDate>
				<author><![CDATA[ tfecw]]></author>
			</item>
			<item>
				<title>Re:Connecting to a DB....([BEA][SQLServer JDBC Driver]No more data available to read.)</title>
				<description><![CDATA[ I totally missed this posting before - sorry about that.  Did you get this solved?]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/296/1376.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/296/1376.page</link>
				<pubDate><![CDATA[Wed, 4 Oct 2006 08:46:27]]> GMT</pubDate>
				<author><![CDATA[ stdunbar]]></author>
			</item>
			<item>
				<title>Re:Connecting to a DB....([BEA][SQLServer JDBC Driver]No more data available to read.)</title>
				<description><![CDATA[  [quote]I totally missed this posting before - sorry about that. Did you get this solved?[/quote]<br /> <br /> <br /> No worries, I don't remember writing this one! <img src="http://forums.hotjoe.com//images/smilies/8a80c6485cd926be453217d59a84a888.gif" /><br /> <br /> restarting the server def fixes the problem (in the short term). There was a setting we had to enable/disable in weblogic to fix it for good. I'll see if i can't get more details on monday so we can update  this for posterity. ]]></description>
				<guid isPermaLink="true">http://forums.hotjoe.com/posts/preList/296/1400.page</guid>
				<link>http://forums.hotjoe.com/posts/preList/296/1400.page</link>
				<pubDate><![CDATA[Sat, 14 Oct 2006 13:39:27]]> GMT</pubDate>
				<author><![CDATA[ tfecw]]></author>
			</item>
	</channel>
</rss>
