Archive for the 'java' Category

Tutoring Java

Tuesday, September 25th, 2007

My lovely wife is always trolling Craigslist, looking to put me to work doing odd jobs.  My latest odd job is a Java tutor.I never took a formal Java class. I bought a book, trolled the web, and was given a project.  The good news is that I don’t have a lot of cruft to [...]

Large Datasets in a Unit Test

Wednesday, September 12th, 2007

I spent my whole day essentially working on one unit test.  Yes, just one unit test. But let me explain.This part of the app just does something very simple — serializes the results of a database query into XML.  Of course, it’s not “simple” but we have tools to make this simple.  You take some [...]

Setting up a JNDI Data Source in Spring

Friday, August 17th, 2007

Just put something like this in your applicationContext.xml <bean id=”appDS” class=”org.springframework.jndi.JndiObjectFactoryBean”>  <property name=”jndiEnvironment”>       <props>        <prop key=”java.naming.factory.initial”>weblogic.jndi.WLInitialContextFactory</prop>        <prop key=”java.naming.provider.url”>t3://localhost</prop>      </props>    </property>     <property name=”jndiName” value=”datasourcejndi_name”>   </property></bean>You’re properties and jndiName will probably be different.  But still — no code, just configuration. It doesn’t get much better than that!Powered by ScribeFire.

Easier Unit Testing in Spring

Friday, July 6th, 2007

If you are using the Spring Framework, you should using Spring’s JUnit-based testing framework. See their docs for details. I’ll try to do a summary for the rest of what it is and why you would want to use it instead of plain JUnit.Here is a skeleton of the unit test class:// AbstractDependencyInjectionSpringContextTests is [...]

Getting Spring To Read Your Log4j Config

Thursday, June 28th, 2007

I’m using The Spring Framework to build a new application. Spring is cool — it can do a lot and there is a lot to learn about it. One cool thing I just figured out it logging injection. One thing that took me a while to figure out is to get Spring [...]

Find (and Fix) bugs with FindBugs

Tuesday, May 15th, 2007

My co-workers have been buzzing about FindBugs for few weeks and it seems cool in theory.  Well, our Lead sent an email out yesterday that we all need to start using it in our development cycle and, since I was waiting for other people to get back to me, I hesitatingly gave it a try.Hesitatingly, [...]

Java, Strings, and Words — oh my

Saturday, April 28th, 2007

My problem seemed easy — I want to capitalize the words in a sentence. So “FRANK BURNS EATS WORMS” become “Frank Burns Eats Worms”. And I wrote a little method that did that and life was good.

But then I realized that I also had strings like “M.A. HOSTETLER (COMPUTER GEEK)” and they would [...]

Treating a log4j log like a database

Wednesday, March 28th, 2007

I’m finally posting a Python module I wrote months ago that I have found to be very handy.

Our log4j log files get big — really big. It doesn’t help that we log just about everything under the sun. This makes it difficult to parse through and find the messages that we are looking [...]

JSON — not just for AJAX

Monday, March 12th, 2007

I recently blogged on the evils of mixing Java and JavaScript in JSP pages but didn’t give any good ways around it.  I mean, you have a list or array in Java and you want JavaScript in the JSP page to access this data — how do you do that?

Let me introduce you to to [...]

Weblogic, Oracle and Blobs — oh my!

Monday, February 12th, 2007

The problem — upload a file and put it into a Blob in an Oracle database. The file upload was easy (Thanks Jakarta!) but saving it to the database was a different story. I found many, many examples on the web, but none of them quite worked. Then I read a post [...]