<?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>Jason B Herald &#187; Java</title>
	<atom:link href="http://jasonbherald.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://jasonbherald.com</link>
	<description>x = sin x</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:18:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Domain Lookup</title>
		<link>http://jasonbherald.com/2009/09/19/domain-lookup/</link>
		<comments>http://jasonbherald.com/2009/09/19/domain-lookup/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 01:43:21 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=310</guid>
		<description><![CDATA[Here is some code to do domain lookup in java (nslookup style): Hashtable env = new Hashtable(); env.put(&#8220;java.naming.factory.initial&#8221;, &#8220;com.sun.jndi.dns.DnsContextFactory&#8221;); DirContext &#8230; <a href="http://jasonbherald.com/2009/09/19/domain-lookup/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>Here is some code to do domain lookup in java (nslookup style):</p>
<blockquote><p>Hashtable env = new Hashtable();<br />
env.put(&#8220;java.naming.factory.initial&#8221;, &#8220;com.sun.jndi.dns.DnsContextFactory&#8221;);<br />
DirContext ictx = new InitialDirContext(env);<br />
Attributes attrs = ictx.getAttributes(&#8220;gmail.com&#8221;, new String[]{&#8220;MX&#8221;});<br />
Attribute attr = attrs.get(&#8220;MX&#8221;);</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2009/09/19/domain-lookup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JBoss Seam</title>
		<link>http://jasonbherald.com/2009/09/03/jboss-seam/</link>
		<comments>http://jasonbherald.com/2009/09/03/jboss-seam/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 00:54:09 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JBoss]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=269</guid>
		<description><![CDATA[So I took up the task of learning to use the JBoss Application server and while the server itself is &#8230; <a href="http://jasonbherald.com/2009/09/03/jboss-seam/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>So I took up the task of learning to use the JBoss Application server and while the server itself is really nice the real power seems to be in a concept called the Seam.<br />
There are 2 Terms to consider when trying to figure out exactly what a seam is:</p>
<p>Bijection :<br />
allows objects to be in-jected or out-jected to/from assigned variables using the @In and @Out annotations</p>
<p>Contexts :<br />
Stateless context<br />
Event (or request) context<br />
Page context<br />
Conversation context<br />
Session context<br />
Business process context<br />
Application context</p>
<p>Most of these contexts are similar to other technologies but the 2 new ones are: conversation context, and business process context.<br />
The <a href="http://docs.jboss.org/seam/1.1GA/reference/en/html/concepts.html" target="_blank">documentation</a> says they are:</p>
<p><strong>3.1.6. Business process context</strong><br />
The business process context holds state associated with the long running business process. This state is managed and made persistent by the BPM engine (JBoss jBPM). The business process spans multiple interactions with multiple users, so this state is shared between multiple users, but in a well-defined manner. The current task determines the current business process instance, and the lifecycle of the business process is defined externally using a process definition language, so there are no special annotations for business process demarcation.</p>
<p><strong>3.1.4. Conversation context</strong><br />
The conversation context is a truly central concept in Seam. A conversation is a unit of work from the point of view of the user. It might span several interactions with the user, several requests, and several database transactions. But to the user, a conversation solves a single problem. For example, &#8220;book hotel&#8221;, &#8220;approve contract&#8221;, &#8220;create order&#8221; are all conversations. You might like to think of a conversation implementing a single &#8220;use case&#8221; or &#8220;user story&#8221;, but the relationship is not necessarily quite exact.</p>
<p>A conversation holds state associated with &#8220;what the user is doing now, in this window&#8221;. A single user may have multiple conversations in progress at any point in time, usually in multiple windows. The conversation context allows us to ensure that state from the different conversations does not collide and cause bugs.</p>
<p>It might take you some time to get used to thinking of applications in terms of conversations. But once you get used to it, we think you&#8217;ll love the notion, and never be able to not think in terms of conversations again!</p>
<p>Some conversations last for just a single request. Conversations that span multiple requests must be demarcated using annotations provided by Seam.</p>
<p>Some conversations are also tasks. A task is a conversation that is significant in terms of a long-running business process, and has the potential to trigger a business process state transition when it is successfully completed. Seam provides a special set of annotations for task demarcation.</p>
<p>Conversations may be nested, with one conversation taking place &#8220;inside&#8221; a wider conversation. This is an advanced feature.</p>
<p>Usually, conversation state is actually held by Seam in the servlet session between requests. Seam implements configurable conversation timeout, automatically destroying inactive conversations, and thus ensuring that the state held by a single user login session does not grow without bound if the user abandons conversations.</p>
<p>Seam serializes processing of concurrent requests that take place in the same long-running conversation context, in the same process.</p>
<p>Alternatively, Seam may be configured to keep conversational state in the client browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2009/09/03/jboss-seam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts 2 validator types</title>
		<link>http://jasonbherald.com/2009/02/05/struts-2-validator-types/</link>
		<comments>http://jasonbherald.com/2009/02/05/struts-2-validator-types/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 15:12:51 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Struts 2]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=185</guid>
		<description><![CDATA[&#60;validator name="required" class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/&#62; &#60;validator name="requiredstring" class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/&#62; &#60;validator name="int" class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/&#62; &#60;validator name="long" class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/&#62; &#60;validator name="short" class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/&#62; &#60;validator name="double" class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/&#62; &#60;validator name="date" &#8230; <a href="http://jasonbherald.com/2009/02/05/struts-2-validator-types/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<div class="code">
<div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;validator name=<span class="code-quote">"required"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"requiredstring"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.RequiredStringValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"int"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"long"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"short"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"double"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"date"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"expression"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.ExpressionValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"fieldexpression"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"email"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.EmailValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"url"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.URLValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"visitor"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.VisitorFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"conversion"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"stringlength"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"regex"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.RegexFieldValidator"</span>/&gt;</span>
<span class="code-tag">&lt;validator name=<span class="code-quote">"conditionalvisitor"</span> class=<span class="code-quote">"com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator"</span>/&gt;</span>
<span class="code-tag"><a href="http://struts.apache.org/2.x/docs/validation.html#Validation-BundledValidators" target="_blank">Link to Ref</a></span></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2009/02/05/struts-2-validator-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts 2 Zip Code Validator</title>
		<link>http://jasonbherald.com/2009/02/05/struts-2-zip-code-validator/</link>
		<comments>http://jasonbherald.com/2009/02/05/struts-2-zip-code-validator/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 15:05:05 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Struts 2]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=184</guid>
		<description><![CDATA[&#60;field name=&#8221;ah.address.zip&#8221;&#62; &#60;field-validator type=&#8221;required&#8221;&#62; &#60;param name=&#8221;trim&#8221;&#62;true&#60;/param&#62; &#60;message&#62;Zip Code is required&#60;/message&#62; &#60;/field-validator&#62; &#60;field-validator type=&#8221;regex&#8221;&#62; &#60;param name=&#8221;expression&#8221;&#62;&#60;![CDATA[^\d{5}$]]&#62;&#60;/param&#62; &#60;message&#62;Zip Code must be 5 &#8230; <a href="http://jasonbherald.com/2009/02/05/struts-2-zip-code-validator/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>&lt;field name=&#8221;ah.address.zip&#8221;&gt;</p>
<p>&lt;field-validator type=&#8221;required&#8221;&gt;<br />
&lt;param name=&#8221;trim&#8221;&gt;true&lt;/param&gt;<br />
&lt;message&gt;Zip Code is required&lt;/message&gt;<br />
&lt;/field-validator&gt;</p>
<p>&lt;field-validator type=&#8221;regex&#8221;&gt;<br />
&lt;param name=&#8221;expression&#8221;&gt;&lt;![CDATA[^\d{5}$]]&gt;&lt;/param&gt;<br />
&lt;message&gt;Zip Code must be 5 characters&lt;/message&gt;<br />
&lt;/field-validator&gt;</p>
<p>&lt;/field&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2009/02/05/struts-2-zip-code-validator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aop</title>
		<link>http://jasonbherald.com/2008/09/27/aop-2/</link>
		<comments>http://jasonbherald.com/2008/09/27/aop-2/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 01:40:22 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=81</guid>
		<description><![CDATA[K so I was going to have an entire AOP example finished tonight but the family ended up stopping by &#8230; <a href="http://jasonbherald.com/2008/09/27/aop-2/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>K so I was going to have an entire AOP example finished tonight but the family ended up stopping by to see the new baby &lt;excuses, excuses&gt; which means the example will have to come tomorrow.  However here is a great synopsis on aspectj to tide you over till then (I want my AOP!):</p>
<ul>
<li><a href="http://www.javaworld.com/javaworld/jw-01-2002/jw-0118-aspect.html">Part 1. Separate software concerns with aspect-oriented programming</a></li>
<li><a href="http://www.javaworld.com/javaworld/jw-03-2002/jw-0301-aspect2.html">Part 2. Learn AspectJ to better understand aspect-oriented programming</a></li>
<li><a href="http://www.javaworld.com/javaworld/jw-04-2002/jw-0412-aspect3.html">Part 3. Use AspectJ to modularize crosscutting concerns in real-world problems</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2008/09/27/aop-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java, Struts and Outputing an Excel File</title>
		<link>http://jasonbherald.com/2008/09/14/java-struts-and-outputing-an-excel-file/</link>
		<comments>http://jasonbherald.com/2008/09/14/java-struts-and-outputing-an-excel-file/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 14:59:51 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=71</guid>
		<description><![CDATA[In a project I was working on last night I needed to output sets of data on demand in excel.  &#8230; <a href="http://jasonbherald.com/2008/09/14/java-struts-and-outputing-an-excel-file/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>In a project I was working on last night I needed to output sets of data on demand in excel.  I found various ways to do this however this was the most simplistic and worked every time on all my computers. (Mac, Linux, XP).</p>
<blockquote>
<pre>response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","inline" );
</pre>
</blockquote>
<p>Those 2 lines make the instant translation of the HTML I put in the page go to excel.  Now something massive to remember here: The formatting is pretty unpredictable if you use css or any fruity styles.  Luckally in my case I didn&#8217;t need to use either; just output the data.</p>
<p>In either case you simply draw the HTML as you would to output a basic page with the response lines telling your browser that excel owns the page.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2008/09/14/java-struts-and-outputing-an-excel-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Absolute Link</title>
		<link>http://jasonbherald.com/2008/06/03/absolute-link/</link>
		<comments>http://jasonbherald.com/2008/06/03/absolute-link/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 19:30:04 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=44</guid>
		<description><![CDATA[This is a fantastic link for finding information about EJB and Hibernate Annotations. So thanks to the guys/gals that produced &#8230; <a href="http://jasonbherald.com/2008/06/03/absolute-link/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>This is a fantastic link for finding information about EJB and Hibernate Annotations.  So thanks to the guys/gals that produced it:</p>
<p><a class="aligncenter" title="Link to Content" href="http://docs.jboss.org/ejb3/app-server/HibernateAnnotations/reference/en/html_single/index.html" target="_blank">Link to Content<br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2008/06/03/absolute-link/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applet File Drop</title>
		<link>http://jasonbherald.com/2008/06/03/applet-file-drop/</link>
		<comments>http://jasonbherald.com/2008/06/03/applet-file-drop/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 15:55:12 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=43</guid>
		<description><![CDATA[I needed to make a way for a person to drag a file off of the desktop and onto the &#8230; <a href="http://jasonbherald.com/2008/06/03/applet-file-drop/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>I needed to make a way for a person to drag a file off of the desktop and onto the browser using a java Applet.  And this is the code to make that happen:</p>
<blockquote><p>public class SomeApplet extends JApplet implements DropTargetListener {</p></blockquote>
<p>The first step is to implement the  DropTargetListener as you extend JApplet (or Applet).  This is going to provide the applet the ability to contain a Drop Target.  That is right, I said &#8220;contain&#8221;.  I have tried this attaching the Drop Target Listener to the Applet itself unsuccessfully however; it attaches fine to a JPanel or even a Label.</p>
<blockquote><p>JPanel jp1 = new JPanel();<br />
DropTarget dt2 = new DropTarget(jp1, this);<br />
jp1.setDropTarget(dt2);</p></blockquote>
<p>Next declare the panel and a Drop Target then attach the drop target to the panel (once again this could be done with a label or whatever).</p>
<blockquote><p>public void drop(DropTargetDropEvent dtde) {<br />
int action = dtde.getDropAction();</p>
<p>dtde.acceptDrop(action);</p>
<p>fromTransferable(dtde.getTransferable());</p>
<p>dtde.dropComplete(true);<br />
}</p></blockquote>
<p>First you get the Drop Action from the dtde object which represents the Drop Target Event then accept the Drop using the acceptDrop function.  This registers the accepted drop with the applet.  Once you accept then you dispatch the function which handles the drop (uploading the file in our case) then tell the applet the drop is complete using the dropComplete function.  This is a great place for error handling to return false if there is an error or true if the drop function was successful.  Both will have different display consequences which can be seen through testing <img src='http://jasonbherald.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<blockquote><p>Object data = t.getTransferData(DataFlavor.javaFileListFlavor);<br />
java.util.List&lt;File&gt; fileList = (java.util.List&lt;File&gt;) data;</p>
<p>for (File file : fileList) {<br />
if (!is_in_list(file_names, file.getAbsolutePath()) &amp;&amp; !file.isDirectory()) {</p></blockquote>
<p>Lastly we cycle through the list of files we got and decide whether to save them or what to do.</p>
<p>And there you have it: a medium level overview on how to drop a file into the browser on an applet and have it upload.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2008/06/03/applet-file-drop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applet and Javascript</title>
		<link>http://jasonbherald.com/2008/05/30/applet-and-javascript/</link>
		<comments>http://jasonbherald.com/2008/05/30/applet-and-javascript/#comments</comments>
		<pubDate>Sat, 31 May 2008 03:59:39 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=42</guid>
		<description><![CDATA[So you have an applet and you want to do one or both of the following things: Run javascript commands &#8230; <a href="http://jasonbherald.com/2008/05/30/applet-and-javascript/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>So you have an applet and you want to do one or both of the following things:</p>
<ol>
<li>Run javascript commands from within your applet</li>
<li>Control your applet through javascript</li>
</ol>
<p>Step 1 Setup the Object Tag:</p>
<blockquote><p>&lt;object type=&#8221;&#8230;&#8221;&gt;<br />
&lt;param name=&#8221;mayscript&#8221; value=&#8221;true&#8221;&gt;<br />
&lt;param name=&#8221;scriptable&#8221; value=&#8221;true&#8221;&gt;<br />
&lt;/object&gt;</p></blockquote>
<p>*Note &#8211; I did not show the archive, code or other params needed to setup an object as they are dependent on your applet.<br />
*Note &#8211; This setup allows for javascript communication in and out of your applet</p>
<p>Step 2 From within the java call some javascript</p>
<blockquote><p>import javascript.*;<br />
&#8230;.<br />
JSObject win = JSObject.getWindow(this);<br />
win.eval(&#8220;alert(&#8216;test&#8217;);&#8221;);</p></blockquote>
<p>*Note &#8211; To make this work you need to add plugin.jar from within your jdk/lib folder in the project classpath and include it in your deployment (archive = &#8220;&#8230;, plugin.jar&#8221;).</p>
<p>And tada you can call java functions (yes the public ones) from javascript just by referencing the id of the object (dot) the function name.  The translation between object types can get a bit tricky if you try to do a map or hash but with strings, ints and the like its pretty straight forward.  The primary use for this was in setting up an event and using javascript to trigger it on submission of a form however the possibilites are endless <img src='http://jasonbherald.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2008/05/30/applet-and-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Blob (JDBC) &#8211; How to</title>
		<link>http://jasonbherald.com/2008/05/27/oracle-blob-jdbc-how-to/</link>
		<comments>http://jasonbherald.com/2008/05/27/oracle-blob-jdbc-how-to/#comments</comments>
		<pubDate>Tue, 27 May 2008 17:38:14 +0000</pubDate>
		<dc:creator>Jason Herald</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jasonbherald.com/?p=41</guid>
		<description><![CDATA[This morning I needed to insert a file&#8217;s contents into a blob on an oracle database so here is the &#8230; <a href="http://jasonbherald.com/2008/05/27/oracle-blob-jdbc-how-to/" class="more-link">Learn more</a>]]></description>
			<content:encoded><![CDATA[<p>This morning I needed to insert a file&#8217;s contents into a blob on an oracle database so here is the method used to do that (look for a future post on dropping a file into an applet).</p>
<blockquote><p>/* File Loaded here into a File Object as f */<br />
PreparedStatement ps = conn.prepareStatement(&#8220;INSERT INTO TBL VALUES(?, ?)&#8221;);<br />
ps.setString(1, f.getName());<br />
FileInputStream fis = new FileInputStream(f);<br />
ps.setBinaryStream(2, fis, fis.available());<br />
ps.execute();<br />
ps.close();</p></blockquote>
<p>And tada your record will be loaded into the blob.</p>
<p>*** Not Shown ***<br />
Oracle JDBC Connection &#8211; This example does not use any framework/connection helper (i.e. Hibernate/EJB)</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonbherald.com/2008/05/27/oracle-blob-jdbc-how-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

