<?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>java Archives - The Story of David Kaspar</title>
	<atom:link href="https://blog.davidkaspar.com/archives/tag/java/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.davidkaspar.com/archives/tag/java</link>
	<description>Online journal and ponderings about the Internet, gadgets and photography.</description>
	<lastBuildDate>Tue, 12 Jul 2011 16:27:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://blog.davidkaspar.com/wp-content/uploads/2020/05/chubby.gif</url>
	<title>java Archives - The Story of David Kaspar</title>
	<link>https://blog.davidkaspar.com/archives/tag/java</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>JSR 303: Combining custom and standard validators</title>
		<link>https://blog.davidkaspar.com/archives/2011/07/jsr-303-combining-custom-and-standard-validators.php</link>
					<comments>https://blog.davidkaspar.com/archives/2011/07/jsr-303-combining-custom-and-standard-validators.php#respond</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Tue, 12 Jul 2011 16:27:49 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[hibernate validator]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jsr 303]]></category>
		<category><![CDATA[validation]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2011/07/12/jsr-303-combining-custom-and-standard-validators/</guid>

					<description><![CDATA[<p>We are using the JSR 303 Bean validation API (Hibernate validator as the implementation) on a project and recently faced a problem. Whenever we were using our own custom validators in combination with standard validators like NotNull and NotEmpty, the standard validators seemed to be ignored. The result was that we were getting NullPointerExceptions in &#8230; <a href="https://blog.davidkaspar.com/archives/2011/07/jsr-303-combining-custom-and-standard-validators.php" class="more-link">Continue reading<span class="screen-reader-text"> "JSR 303: Combining custom and standard validators"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2011/07/jsr-303-combining-custom-and-standard-validators.php">JSR 303: Combining custom and standard validators</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We are using the <a href="http://jcp.org/en/jsr/detail?id=303">JSR 303 Bean validation</a> API (<a href="http://www.hibernate.org/subprojects/validator.html">Hibernate validator</a> as the implementation) on a project and recently faced a problem.<br />
Whenever we were using our own custom validators in combination with standard validators like NotNull and NotEmpty, the standard validators seemed to be ignored.<br />
The result was that we were getting NullPointerExceptions in our custom validators and sometimes we were getting duplicate error messages for the same invalid field.<br />
I haven&#8217;t poured over all of the JSR 303 documentation in detail so maybe I&#8217;ve missed a recommended best practice but the following code in the default NotBlankValidator gave me a hint.</p>
<pre style='color:#000020;background:#f6f8ff;'>public boolean isValid<span style='color:#308080; '>(</span><span style='color:#003060; '>String</span> s<span style='color:#308080; '>,</span>
ConstraintValidatorContext constraintValidatorContext<span style='color:#308080; '>)</span> <span style='color:#406080; '>{</span>
<span style='color:#200080; font-weight:bold; '>if</span> <span style='color:#308080; '>(</span> s <span style='color:#308080; '>=</span><span style='color:#308080; '>=</span> null <span style='color:#308080; '>)</span> <span style='color:#406080; '>{</span>
<span style='color:#200080; font-weight:bold; '>return</span> true<span style='color:#406080; '>;</span>
<span style='color:#406080; '>}</span>
<span style='color:#308080; '>.</span><span style='color:#308080; '>.</span><span style='color:#308080; '>.</span>
</pre>
<p>Why would you ever return true (i.e. valid) for an input that is null? That doesn&#8217;t make sense until you realise that validation is a *combination* of all constraints.<br />
This means that your validator should only return false for your specific test. If it fails for a chained validation, for example if input is null, it should return true and rely on the NotNull validation to report that error.<br />
You still have to guard for null and empty inputs but return true if they occur rather then returning false.<br />
Hide any required basic validations inside your custom constraint annotation. For example NotBlank does that:</p>
<pre style='color:#000020;background:#f6f8ff;'>...
@NotNull
<span style='color:#200080; font-weight:bold; '>public</span> @<span style='color:#200080; font-weight:bold; '>interface</span> NotBlank <span style='color:#406080; '>{</span>
<span style='color:#308080; '>.</span><span style='color:#308080; '>.</span><span style='color:#308080; '>.</span>
</pre>
<p>The post <a href="https://blog.davidkaspar.com/archives/2011/07/jsr-303-combining-custom-and-standard-validators.php">JSR 303: Combining custom and standard validators</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2011/07/jsr-303-combining-custom-and-standard-validators.php/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Caching the remote interface of a Stateless Session Bean</title>
		<link>https://blog.davidkaspar.com/archives/2004/09/caching-the-remote-interface-of-a-stateless-session-bean.php</link>
					<comments>https://blog.davidkaspar.com/archives/2004/09/caching-the-remote-interface-of-a-stateless-session-bean.php#respond</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Wed, 01 Sep 2004 15:01:53 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[stateful session bean]]></category>
		<category><![CDATA[stateless]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2004/09/01/caching-the-remote-interface-of-a-stateless-session-bean/</guid>

					<description><![CDATA[<p>We have asked this question several times in our organisation and I have seen it being asked many times in various web forums. I suspect that the reason why there is no correct answer is that it all depends on your environment. Some people report very good results with one approach but the same approach &#8230; <a href="https://blog.davidkaspar.com/archives/2004/09/caching-the-remote-interface-of-a-stateless-session-bean.php" class="more-link">Continue reading<span class="screen-reader-text"> "Caching the remote interface of a Stateless Session Bean"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/09/caching-the-remote-interface-of-a-stateless-session-bean.php">Caching the remote interface of a Stateless Session Bean</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We have asked this question several times in our organisation and I have seen it being asked many times in various web forums.<br />
I suspect that the reason why there is no correct answer is that it all depends on your environment.<br />
Some people report very good results with one approach but the same approach may not be efficient or not even functional somewhere else; such as in a clustered environment.<br />
<u>The options:</u><br />
1. A common basic approach is to store the reference to the remote interface in the http session. Once it has been stored, all clients can quickly access business methods of the stateful session bean. You should use <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html" title="Business delegate pattern">business delegates</a> to communicate with your EJBs.<br />
According to the specification  (EJB spec 2.1FR, section 7.8):</p>
<blockquote><p>There is no fixed mapping between clients and stateless instances. The container simply delegates a client&rsquo;s work to any available instance that is method-ready.</p></blockquote>
<p>This means that even with a single remote interface, the container will delegate what bean instance should serve a client call.<br />
With stateful beans the case is the contrary. A remote interface will always guarantee calls are delegated to the <b>same stateful session bean</b>. This of course is crucial to enable a dialog between a client and a stateful bean.<br />
2. The JNDI lookup of a home interface is the costly part of locating an EJB. As such, storing a reference to the home interface is a second approach.<br />
Because application servers may use the <i>create()</i> method as load balancing trigger this approach may behave better in a clustered environment. Consider using the <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html">service locator pattern</a> to collect all your service lookups to a single point.<br />
3. A handle to an EJB has the advantage of being serialisable and valid between multiple JVMs. It seems to be the superior way of storing a reference to an EJB.<br />
It is only possible to acquire a handle to EJBs that implement remote interfaces. With EJB 2.0, you will see that many EJBs implement local interfaces only to improve performance. Only the session facades will be exposing both local and remote interfaces.<br />
<u>Conclusion:</u><br />
To be future proof, it is safest to assume as little as possible about the behaviour of your J2EE server and avoiding short cuts.<br />
This will ensure that your application can move from a testing environment to a full clustered, load balanced production environment or a different j2ee application server.<br />
JNDI lookups of the home interface is the expensive operation so implement a service locator that caches home interfaces. Make sure all of your code is using this single point of looking up EJBs. It will then be possible to change the lookup strategy in the future if needed.<br />
<u>References:</u><br />
<a href="http://www.theserverside.com">The server side</a><br />
<a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html">Service Locator pattern</a><br />
<a href="http://java.sun.com/products/ejb/docs.html">EJB 2.1 Specification</a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/09/caching-the-remote-interface-of-a-stateless-session-bean.php">Caching the remote interface of a Stateless Session Bean</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2004/09/caching-the-remote-interface-of-a-stateless-session-bean.php/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Hello J2ME World</title>
		<link>https://blog.davidkaspar.com/archives/2004/05/hello-j2me-world.php</link>
					<comments>https://blog.davidkaspar.com/archives/2004/05/hello-j2me-world.php#respond</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Wed, 26 May 2004 14:50:48 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ericsson]]></category>
		<category><![CDATA[j2me]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JSR]]></category>
		<category><![CDATA[midlet]]></category>
		<category><![CDATA[MIDP]]></category>
		<category><![CDATA[MMAPI]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[sony]]></category>
		<category><![CDATA[sonyericsson]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[t610]]></category>
		<category><![CDATA[t630]]></category>
		<category><![CDATA[WTK]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2004/05/26/hello-j2me-world/</guid>

					<description><![CDATA[<p>With my recent upgrade to SonyEricsson T630, a new geek opportunity presented it self: to develop Java applications for my very own mobile. Priceless. Because I am fairly familiar with Java and the fantastic, open source, IDE NetBeans it was easy to develop and deploy my first HelloJ2MEWorld application. NetBeans has an extension module focused &#8230; <a href="https://blog.davidkaspar.com/archives/2004/05/hello-j2me-world.php" class="more-link">Continue reading<span class="screen-reader-text"> "Hello J2ME World"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/05/hello-j2me-world.php">Hello J2ME World</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>With my recent upgrade to <a href="http://www.sonyericsson.com/t630/" title="SonyEricsson t630">SonyEricsson T630</a>, a new geek opportunity presented it self: to develop <a href="http://www.getjar.com/" title="Free Java apps and games for mobiles">Java applications</a> for my very own mobile. Priceless.<br />
Because I am fairly familiar with Java and the fantastic, open source, IDE <a href="http://www.netbeans.org">NetBeans</a> it was easy to develop and deploy my first HelloJ2MEWorld application.<br />
NetBeans has an extension module focused on J2ME development. Download it and NetBeans will be able to help you with your Midlets, JARs and obfuscation.<br />
NetBeans is using the Sun J2ME SDK. If you want to be more device specific, I&#8217;d recommend you to download an SDK directly from the mobile maker you are interested in. Two obvious choices are <a href="http://developer.sonyericsson.com" title="SE mobile development site">SonyEricsson</a> and <a href="http://www.forum.nokia.com/main/0,6566,033,00.html" title="Nokia tools">Nokia</a>.<br />
Try out and debug your application on one of the supplied emulators.<br />
The last step is to transfer your application to your mobile. You have a choice between infrared, bluetooth, USB cable and Over-the-air (OTA). Since I am developing on a IR enabled laptop, ir was the best option for me.<br />
First application that came to mind for developing was of course a mobile blogging tool. A quick search on Google returned the just started open source project <a href="http://sourceforge.net/projects/midlog/">MIDLog</a>. So instead of starting from scratch and probably duplicating all work done in MIDLog, I am hoping to contribute to MIDLog.<br />
The J2ME world is crowded with two main MIDP versions, WTK versions and various JSRs (Java Specification Requests). While many exciting features are planned for future version of J2ME, todays devices are very limited.<br />
Example, the T630 supports the &#8220;new&#8221; multimedia API (MMAPI &#8211; JSR 135) but Sony has chosen to support the sound part only. This means that there is no support for image capturing and I suspect this will make it very difficult to develop a mobile blog tool capable of posting images.</p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/05/hello-j2me-world.php">Hello J2ME World</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2004/05/hello-j2me-world.php/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Netbeans 3.6</title>
		<link>https://blog.davidkaspar.com/archives/2004/04/netbeans-3-6.php</link>
					<comments>https://blog.davidkaspar.com/archives/2004/04/netbeans-3-6.php#respond</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Thu, 22 Apr 2004 14:41:09 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[open source]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2004/04/22/netbeans-3-6/</guid>

					<description><![CDATA[<p>I have been using NetBeans 3.6 for a couple of days now and can say it&#8217;s a very good improvement on the previous version 3.5.1. (NetBeans is a free, open source development tool. Mainly for Java development but also suitable for C/C++) The intention was to wait until end of summer 2004 and release version &#8230; <a href="https://blog.davidkaspar.com/archives/2004/04/netbeans-3-6.php" class="more-link">Continue reading<span class="screen-reader-text"> "Netbeans 3.6"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/04/netbeans-3-6.php">Netbeans 3.6</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" src="http://www.davidkaspar.com/pics/netbeans36.jpg" width="150" height="112" alt="" border="0" class="floatleft" />I have been using NetBeans 3.6 for a couple of days now and can say it&#8217;s a very good improvement on the previous version 3.5.1.<br />
(NetBeans is a free, open source development tool. Mainly for Java development but also suitable for C/C++)<br />
The intention was to wait until end of summer 2004 and release version 4.0 but because of the fierce competition (<a href="http://www.eclipse.org/" title="Eclipse IDE">Eclipse</a>, <a href="http://www.intellij.com/idea/" title="IntelliJ IDEA">IntelliJ</a>, <a href="http://www.borland.com/jbuilder/" title="JBuilder">JBuilder</a> and etc) an intermediate version was released with promises of what is to come.<br />
The most prominent change is that the window system has been completely redone. Away with the clunky and very Java-ish interface. In with a leaner, more native looking and intuitive one.<br />
While I suspect that this enhancement required a lot of work input, the user will not notice too much difference (this is good).<br />
Other useful features include code folding, smart brackets, help with overriding methods, Servlet 2.4 and JSP 2.0 code completion and <a href="http://www.netbeans.org/community/releases/36/Whats_New.html" title="Whats new in 3.6">much more</a>.<br />
In previous versions it was needed to download several modules after an install but they all seem to be included in 3.6: database explorer, XML/XSL support, tasklists and more.<br />
NetBeans 3.6 support J2SDK 1.4.1 and above but prefers 1.4.2 so make sure to update it from <a href="http://java.sun.com/j2se/1.4.2/download.html" title="J2SDK">Sun web site</a>.</p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/04/netbeans-3-6.php">Netbeans 3.6</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2004/04/netbeans-3-6.php/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Validating a DB Connection</title>
		<link>https://blog.davidkaspar.com/archives/2004/04/validating-a-db-connection.php</link>
					<comments>https://blog.davidkaspar.com/archives/2004/04/validating-a-db-connection.php#comments</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Fri, 02 Apr 2004 15:55:19 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[close]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[statement]]></category>
		<category><![CDATA[validate]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2004/04/02/validating-a-db-connection/</guid>

					<description><![CDATA[<p>You may have been tempted to execute Connection.isClosed() to test whether a connection is live and can be reused. This is however not sufficient as the Sun JDBC API guide states: &#8220;Note that the method Connection.isClosed is guaranteed to return true only when it is called after the method Connection.close has been called. As a &#8230; <a href="https://blog.davidkaspar.com/archives/2004/04/validating-a-db-connection.php" class="more-link">Continue reading<span class="screen-reader-text"> "Validating a DB Connection"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/04/validating-a-db-connection.php">Validating a DB Connection</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>You may have been tempted to execute Connection.isClosed() to test whether a connection is live and can be reused. This is however not sufficient as the Sun JDBC API guide states:</p>
<p>&#8220;Note that the method Connection.isClosed is guaranteed to return true only when it is called after the method Connection.close has been called. As a result, a programmer cannot depend on this method to indicate whether a connection is valid or not. Instead, a typical JDBC client can determine that a connection is invalid by catching the exception that is thrown when a JDBC operation is attempted.&#8221;</p>
<p>The only safe way of ensuring that a connection is valid is to execute a tiny query and catch any SQLExceptions thrown. If no exceptions are thrown, you can go on and using that connection.</p>
<p>If any exceptions are thrown, it is safest to close that connection, set the reference to null and create a new connection.</p>
<p>What query to execute?</p>
<p>It would be nice to execute a general (database independent) method like Connection.getMetaData(). Unfortunately I have seen some indication that this may be successful even when a connection is invalid.</p>
<p>To be on the safe side it is best to execute a query like &#8220;SELECT COUNT(*) FROM <dbtable> WHERE 1 = -1&#8243;. We are using SQL server so the table <i>sysusers</i> is a safe bet:</p>
<p><font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">/**</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;A&nbsp;method&nbsp;that&nbsp;tests&nbsp;whether&nbsp;a&nbsp;connection&nbsp;is&nbsp;valid&nbsp;by&nbsp;executing<br />
simple&nbsp;query&nbsp;and&nbsp;catch&nbsp;any&nbsp;exceptions</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*/</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>private&nbsp;</b></font><font color="#7f0055"><b>boolean&nbsp;</b></font><font color="#000000">connectionIsValid</font><font color="#000000">(Connection dbConn)&nbsp;{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//log.debug(&#34;ENTER&nbsp;connectionIsValid():&nbsp;&#34;+dbConn);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>boolean&nbsp;</b></font><font color="#000000">result&nbsp;=&nbsp;</font><font color="#7f0055"><b>true</b></font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">PreparedStatement&nbsp;psr&nbsp;=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>try&nbsp;</b></font><font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//Prepared&nbsp;statement&nbsp;is&nbsp;used&nbsp;to&nbsp;cache&nbsp;the&nbsp;compiled&nbsp;SQL</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">psr&nbsp;=&nbsp;dbConn.prepareStatement</font><font color="#000000">(</font><font color="#2a00ff">&#34;SELECT&nbsp;COUNT(*)&nbsp;FROM&nbsp;sysusers&nbsp;WHERE&nbsp;1&nbsp;=&nbsp;-1&#34;</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">psr.executeQuery</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#7f0055"><b>catch&nbsp;</b></font><font color="#000000">(</font><font color="#000000">SQLException&nbsp;e</font><font color="#000000">)&nbsp;{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">log.debug</font><font color="#000000">(</font><font color="#2a00ff">&#34;Excpetion&nbsp;occured,&nbsp;connection&nbsp;is&nbsp;not&nbsp;valid.&nbsp;&#34;</font><font color="#000000">+e.getMessage</font><font color="#000000">())</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>try&nbsp;</b></font><font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">dbConn.close</font><font color="#000000">()</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//dbConn&nbsp;is&nbsp;never&nbsp;null&nbsp;at&nbsp;this&nbsp;point</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">dbConn=</font><font color="#7f0055"><b>null</b></font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#7f0055"><b>catch&nbsp;</b></font><font color="#000000">(</font><font color="#000000">Exception&nbsp;ee</font><font color="#000000">)&nbsp;{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//quite</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">result&nbsp;=&nbsp;</font><font color="#7f0055"><b>false</b></font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#7f0055"><b>finally&nbsp;</b></font><font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>try&nbsp;</b></font><font color="#000000">{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//free&nbsp;up&nbsp;resource&nbsp;kept&nbsp;by&nbsp;the&nbsp;test&nbsp;statement</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">psr!=</font><font color="#7f0055"><b>null</b></font><font color="#000000">)&nbsp;{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">psr.close</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">psr=</font><font color="#7f0055"><b>null</b></font><font color="#000000">;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#7f0055"><b>catch&nbsp;</b></font><font color="#000000">(</font><font color="#000000">Exception&nbsp;e</font><font color="#000000">)&nbsp;{</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//quite</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//log.debug(&#34;EXIT&nbsp;connectionIsValid():&nbsp;&#34;+result);</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#000000">result;</font><br />
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2004/04/validating-a-db-connection.php">Validating a DB Connection</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2004/04/validating-a-db-connection.php/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Netbeans IDE, pros and cons</title>
		<link>https://blog.davidkaspar.com/archives/2003/11/netbeans-ide-pros-and-cons.php</link>
					<comments>https://blog.davidkaspar.com/archives/2003/11/netbeans-ide-pros-and-cons.php#comments</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Thu, 27 Nov 2003 11:48:22 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[integrated]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jbuilder]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[vss]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2003/11/27/netbeans-ide-pros-and-cons/</guid>

					<description><![CDATA[<p>NetBeans IDE has been my prefered IDE for the last 1.5 years. The reasons are several. OpenSource software, continuously extended and last but not least, it is free. While it doesn&#8217;t have as many features as some &#163;3,000+ IDEs, it has enough to keep you busy. The features that I find most useful and use &#8230; <a href="https://blog.davidkaspar.com/archives/2003/11/netbeans-ide-pros-and-cons.php" class="more-link">Continue reading<span class="screen-reader-text"> "Netbeans IDE, pros and cons"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2003/11/netbeans-ide-pros-and-cons.php">Netbeans IDE, pros and cons</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" src="http://www.davidkaspar.com/pics/netbeans.jpg" width="150" height="174" alt="" border="0" align="right" hspace="10" /><a href="http://www.netbeans.org/" title="Netbeans.org">NetBeans IDE</a> has been my prefered IDE for the last 1.5 years. The reasons are several. OpenSource software, continuously extended and last but not least, it is free. While it doesn&#8217;t have as many features as some &pound;3,000+ IDEs, it has enough to keep you busy.<br />
<img decoding="async" src="http://www.davidkaspar.com/pics/plus.gif" width="83" height="83" alt="" border="0" align="left" hspace="10" />The features that I find most useful and use every day because they speed up the development.<br />
There is the DB explorer that lets me browse a data base to see the tables, data types, values and lets me execute any queries (including updates).</p>
<p><span id="more-106"></span><br />
The CVS integration is great as it lets your check in and out source files directly from the development environment. I have only tested it together with <a href="http://msdn.microsoft.com/ssafe/" title="Microsoft VSS">Microsoft VSS</a> (what a pain that is btw) but it supports other CVS profiles. While it is handy it can be a bit slow on large directory structures so I tend to use it for single files only. When I want to manipulate large amount of source files, I use the VSS client instead.<br />
NetBeans has good XML and XSL support. It lets you validate your XML documents and you can do XSL transformations right there in the IDE. No XSLT debugging though, so get your self a decent XSL IDE (XML Spy or Xcelerator) for serious XSLT.<br />
Javadocs are always tedious to write but NetBeans makes your life little bit easier. It has a nice JavaDoc GUI where all the important fields are listed. It can also auto correct missing fields for you which again saves time.<br />
<a href="http://ant.apache.org/" title="Ant home">Ant</a> is integrated in a way that you can browse your build.xml files and execute specific targets.<br />
If you ever need to write localised property files NetBeans helps out with that as well. It will display keys and the various localised values in a matrix, making it easier to modify them all at once.<br />
The GUI Editing in NetBeans looks extensive but I have not got around using it since all work has been web related and did not include any AWT or Swing coding.<br />
<img loading="lazy" decoding="async" src="http://www.davidkaspar.com/pics/minus.gif" width="61" height="61" alt="" border="0" align="left" hspace="10" />There are some disadvantages that I have found. I miss a refactoring functionality the most. Other IDE&#8217;s (eg <a href="http://www.intellij.com/idea/" title="IntelliJ IDEA">IntelliJ</a>) have features like &#8220;find usages&#8221; of a method or &#8220;refactor&#8221; that lets you change package and method names across the whole source. With NetBeans, I have to use the &#8220;Find&#8230;&#8221; functionality and manually make any changes.<br />
Large projects often have source code across multiple modules and directories but are built into one single directory structure. One approach that other IDEs take is that they allow you to set up matching patterns on where to build a source. You probably want different directories for Servlets and other front-end classes, libraries and EJBs. NetBeans is very difficult to set up to build to multiple targets. One has to basically manually specify the build directory for each source file&#8230; time consuming.<br />
I also miss J2EE support (templates, wizards). Having grown custom to <a href="http://www.borland.com/jbuilder/" title="JBuilder">Borland JBuilder</a>&#8216;s J2ee support I find some task very repetitive and manual in NetBeans.<br />
Another new and upcoming OpenSource IDE is <a href="http://www.eclipse.org/" title="Eclipse">Eclipse</a>. Some knowledgeable people (<a href="http://bladesys.demon.co.uk/roller/page/sradford/Weblog" title="Sean's blog">Sean</a> and <a href="http://www.raibledesigns.com/page/rd" title="Matt's blog">Matt</a>) have been swearing by it, saying that it is indeed better than NetBeans. I had a brief look at it but because the UI and other crucial details seems to be working differently I did not dare to use it for actual development yet.</p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2003/11/netbeans-ide-pros-and-cons.php">Netbeans IDE, pros and cons</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2003/11/netbeans-ide-pros-and-cons.php/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>java.io.Reader issues</title>
		<link>https://blog.davidkaspar.com/archives/2003/10/java-io-reader-issues.php</link>
					<comments>https://blog.davidkaspar.com/archives/2003/10/java-io-reader-issues.php#comments</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Sat, 25 Oct 2003 13:18:56 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[inputsource]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[reader]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2003/10/25/java-io-reader-issues/</guid>

					<description><![CDATA[<p>I have developed an XML converter that is based on the Castor framework. It is quite simple as it takes certain Java objects (beans, collections and maps) and returns an XML representation. Actually I have implemented it so it returns an InputSource which goes well with the next step in the process, the Xalan transformation. &#8230; <a href="https://blog.davidkaspar.com/archives/2003/10/java-io-reader-issues.php" class="more-link">Continue reading<span class="screen-reader-text"> "java.io.Reader issues"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2003/10/java-io-reader-issues.php">java.io.Reader issues</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I have developed an XML converter that is based on the Castor framework. It is quite simple as it takes certain Java objects (beans, collections and maps) and returns an XML representation.<br />
Actually I have implemented it so it returns an InputSource which goes well with the next step in the process, the Xalan transformation.<br />
The problem I am having is that the InputSource can only be used once whereas we would like to use it multiple times. At least once to log the converted XML and second time for the XSLT. As soon as the input source has been used for logging purposes of the XML, the internal reader is empty and I have not found any way of resetting it.<br />
I see two solutions. Either redesign the XMLConverter to store the XML content internally in a different way or write a utility that copies the content of one reader to another reader, while it outputs the content.</p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2003/10/java-io-reader-issues.php">java.io.Reader issues</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2003/10/java-io-reader-issues.php/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>And all that Work</title>
		<link>https://blog.davidkaspar.com/archives/2003/10/and-all-that-work.php</link>
					<comments>https://blog.davidkaspar.com/archives/2003/10/and-all-that-work.php#respond</comments>
		
		<dc:creator><![CDATA[David Kaspar]]></dc:creator>
		<pubDate>Sat, 18 Oct 2003 12:57:10 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[castor]]></category>
		<category><![CDATA[data access object]]></category>
		<category><![CDATA[ejb 2.0]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[xalan]]></category>
		<category><![CDATA[xdoclet]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsl]]></category>
		<guid isPermaLink="false">https://davidkaspar.com/wp/2003/10/18/and-all-that-work/</guid>

					<description><![CDATA[<p>I wish the title was saying &#8216;And all that Jazz&#8216; but it is not because it is Saturday noon and I am working. At least it is from my own bed and with Ginger next to me. The annoying thing with the recent project has been lack of design and the scope of technologies that &#8230; <a href="https://blog.davidkaspar.com/archives/2003/10/and-all-that-work.php" class="more-link">Continue reading<span class="screen-reader-text"> "And all that Work"</span></a></p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2003/10/and-all-that-work.php">And all that Work</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I wish the title was saying &#8216;And <a href="http://imdb.com/title/tt0078754/" title="All that Jazz at IMDB">all that Jazz</a>&#8216; but it is not because it is Saturday noon and I am working. At least it is from my own bed and with <a href="http://photos.davidkaspar.com/v/weddingbw/55380023_G" title="BW Photo of Ginger">Ginger</a> next to me.<br />
The annoying thing with the recent project has been lack of design and the scope of technologies that are in use simultaneously. I have no problems working with a couple of those technologies but all at once takes away some of the concentration.<br />
We are using an unorthodox mix of <a href="http://java.sun.com/blueprints/patterns/DAO.html" title="Data Access Object pattern at Sun">Data Access Objects</a> (DAOs) and <a href="http://java.sun.com/products/ejb/2.0.html" title="EJB specification at Sun">EJB 2.0</a>. What we learned was that you have to watch out not using both technologies to update your precious data base tables. If you do, the EJB container locks the tables and your DAO methods start failing and rolling back to left and right.<br />
I have previously used <a href="http://xdoclet.sourceforge.net/" title="XDoclet  Attribute-Oriented Programming">XDoclet</a> to help with the formalities of EJB 2.0 and <a href="http://jakarta.apache.org/struts/" title="Struts web application framework">Struts framework</a>. This time we have not taken the time (pun intended) to set up XDoclets so it is a pain every time the data model changes or the EJB implementation is updated and the interfaces need to be updated accordingly. At this point of the project, nearly end, it doesn&#8217;t make sense to start adding XDoclet tags and modifying the Ant build scripts but I have made a mental note to use XDoclets from the beginning next time.<br />
The front-end is prepared for internalization and device independent rendering by using XML/XSL. I found that the <a href="http://castor.exolab.org/xml-mapping.html" title="Castor XML Mapping">Castor frame work</a> is great for converting your complex Java objects to an XML representation. Later <a href="http://xml.apache.org/xalan-j/" title="Xalan">Xalan</a> is used for the XSL transformations. One trick from the big bag of tricks is to have <i>dynamic</i> XSL style sheets by using JSPs. This allows us to use constants from our standard Java interfaces and to internalize our pages with the help of JSTL.<br />
<a href="http://ws.apache.org/axis/" title="Axis web services">Axis</a> framework is a great help for setting up web services for cross application wide services and sending those <a href="http://ws.apache.org/soap" title="SOAP">SOAP</a> calls.<br />
There has not been as much <a href="http://www.junit.org/" title="Testing Resources for Extreme Programming">JUnit</a> testing as we first anticipated due to lack of time. Instead of writing JUnit suits for all classes I have only written tests for core utilities that are used by several modules in the application. It was quicker to write the tests and making sure the utilities pass than to face <a href="http://dictionary.reference.com/search?q=kludgy" title="Dictionary">kludgy</a> code that would need thorough debugging.<br />
The mix of everything is fun but just when you are getting groovy with the required on-the-fly design and UML modeling you are interrupted by some nasty JavaScript debugging or even worse, CSS problems.<br />
I wish we find the resources to have a couple of front end developers (scary, MS Word just highlighted the last word because it found the same entry in my Outlook contacts, too smart for my liking).</p>
<p>The post <a href="https://blog.davidkaspar.com/archives/2003/10/and-all-that-work.php">And all that Work</a> appeared first on <a href="https://blog.davidkaspar.com">The Story of David Kaspar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.davidkaspar.com/archives/2003/10/and-all-that-work.php/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
