Apr 08 2008

Using Apache Commons DBUtils and DBCP

Published by under Java

For a project recently, I had the pleasure of working with both DBUtils and DBCP (Database Connection Pooling) from the Apache commons libraries. Both of these libraries together helped me to quickly create a simple, extensible DAO layer for my project. Both libraries include some great default features that I used right out of the box, without any configuration or fuss. In the post I’ll be talking about, and showing an example of using DBUtils. I will also show a quick and easy way to get a DataSource using DBCP.
Continue Reading »

2 responses so far

Feb 22 2008

How Jim Blandy Pronounces “Subversion”

Published by under Oddities

Found this by accident and thought it was hilarious. :)

How to Pronounce “Subversion”

Comments Off on How Jim Blandy Pronounces “Subversion”

Dec 21 2007

Using the New java.io.Console Class

Published by under Java

The 1.6 release of the JDK included a new java.io.Console class, which adds some new features to enhance and simplify command-line applications. Notably, Console includes a method specifically for reading passwords that disables console echo and returns a char array; both important for security.
Continue Reading »

11 responses so far

Oct 18 2007

Yummy Web Service Goodness

Published by under Java,Web

I’m not sure why I haven’t ventured into the realm of web services before this week. It probably has a lot to do with time (or lack thereof) and the type of projects I’ve worked on. But, I finally got my feet wet this week. My employer asked me to create a web service that publishes a service that we currently offer via a JSP web application. As I found out, the back-end logic is unnecessarily complex. To complicate matters the app is written using old-style JSP that is inundated with scriptlets and scattered across many smaller pages which are included based on if-then logic within the scriptlets. Yeah, it’s a mess. So, I read up on XML Schema and WSDL formats and created a WSDL. I know a lot of frameworks create the WSDL for you based on your objects, but I’ve heard that the WSDL-first approach is better for interoperability across platforms. I used Apache Axis as the WS framework because that’s what our project already used to consume web services, I just found out we’re switching from Tomcat to WebLogic and using the WebLogic web service framework. Nice. Good thing I used the WSDL-first approach. Should be a snap to convert. We’ll see.

Comments Off on Yummy Web Service Goodness

Sep 17 2007

Cloning an Object Using Reflection

Published by under snippets

Here’s a quick and dirty way to do a shallow copy of an object by overriding the clone method of Object. If you want to do deep copying, you’ll have to fidget with this a little more…or maybe I’ll do another blog about doing recursive cloning for deep copying. We’ll see.
Continue Reading »

3 responses so far

Aug 21 2007

Sending Serializable Object Data to Standard Out

Published by under Oddities

I can’t really think of a good reason why you’d want t send object data to std out (System.out), but I recently had a project requirement that a parent process read the output from a child process. The child process output was complex, so I wondered if I could send it as object data instead of text. I was told, “You can’t do that”, which is when I knew that I would find a way. Turns out, it was easier than expected. As you’ve probably guessed, sending text would be faster. I didn’t time it against sending text, so I don’t know by how much. If you time it, let me know your results.

Continue Reading »

Comments Off on Sending Serializable Object Data to Standard Out

Dec 21 2005

JTree Drag and Drop Gotcha

Published by under Old Restored

Before adding Drag and Drop capabilities to my JTable, I read Java Tip 97 and Java Tip 114 from JavaWorld. They were fairly helpful, but I ended up doing things a little differently. In implementing my Drag and Drop JTree, however, I was plagued by a persistent exception: “InvalidDnDOperationException: Drag and drop in progress.” I debugged my code for hours before finally finding the source of the error. Somewhere along the line I had called tree.setDragEnabled( true ), which is what caused the error. You will always get this error if you call setDragEnabled ( true ) while also creating a DragSource using your JTree. My completed Drag and Drop enabled JTree can be found here if anyone is interested in using it. It contains a lot of other methods related to my specific project that you’ll have to wade through and remove. But if you focus on the Drag and Drop related methods, you’ll get the gist of how it’s done.

4 responses so far

Dec 12 2005

Java News-reader Application

Published by under Old Restored

I started working on a news aggregator application as my semester project last month, but it has turned into much more than the simple RSS reader is started out as. It now reads all versions of RSS, RDF and Atom. I’ve also updated the GUI to have a nicer look and feel. Here’s are some screen captures.
Jreader 1JReader 2JReader 3

There’s still some work to be done before ComputerFest contest in February, but it’s coming along nicely. I’ll be offering it for beta testing when I get all of the minimum features added. If you’re interested, check back in the next week or so and I should have something posted for download.

3 responses so far

Dec 01 2005

The RSS Version Fiasco

Published by under Old Restored

I’ve recently been extending my Java RSS/Atom feed reader to support more versions of RSS. In doing so I’ve discovered that the version history of RSS is a lot more complicated than I’d thought. One would assume that the version history was linear from 0.9 through 2.0, but one would be wrong. Versions 0.9, 0.91, 0.92, and 0.93 all follow the same branch, but version 1.0 forks from this branch to form it’s own specification that uses the rdf namespace. And adding to the confusion, version 2.0 is a continuation of 0.93. (Here’s a good article with links to information about the history of RSS, the fork, and the Atom format.) As someone with no knowledge of this fork, I’ve looked through scores of RSS feeds, trying to reconcile the obvious differences in version formats. When I read about the fork, it finally made sense. Whew. But man, what a pain in the butt. I now have to write SAX parsers that read and validate all of these differeng standards. I guess it’s better than wriing an HTML parser!  

Comments Off on The RSS Version Fiasco

Nov 29 2005

New System Tray API in JDK 6 (Mustang)

Published by under Old Restored

Robert Eckstein writes:

The latest beta version of the Java 2 Platform Standard Edition 6.0 version (Mustang) now lets you access the system tray in Java with the help of two separate classes in the java.awt package: SystemTray and TrayIcon. These classes give you the ability to add graphics, popup menus, and floating tip functionality to the system tray. If approved by the JSR 270 Expert Group through the Java Community Process, you can expect to find this feature in the final version of Mustang.

Article here I’ve also recently tried the built-in splash screen API that Mustang will ship with. Pretty nifty.

Comments Off on New System Tray API in JDK 6 (Mustang)

« Prev - Next »