MySQL Disaster Recovery

Background You’ve accidentally deleted some or all of the rows in a table, or even dropped a schema object altogether, in a production MySQL database. You need to recover the database to the point right before the accidental statements (DML or DDL) were executed, in essence undoing them. What You’ll Need A recent backup file Read More …

Multihomed Hosts and Java RMI

It can be challenging to get Java RMI communication working right between components on multihomed hosts. To see why, it’s important to understand how RMI determines the server hostname, which ultimately ends up being passed around in RMI stubs. If a client uses an RMI stub to make a remote method call and can’t connect Read More …

XPath for Namespaces

Today I was confronted with the problem of obtaining a list of all namespace attributes for a given XML document. I found that it’s possible to achieve this quickly using the XPath expression //namespace::*, which leverages the namespace axis defined in the XPath 1.0 specification. I’m using Xalan bundled with Sun JDK 1.6, and so Read More …

Downloading JDK 1.5?

It’s more difficult to download Sun’s JDK 1.5 now (version 1.5.0_22 to be precise as I write this) that the company has officially announced its end-of-life.  Downloading it by following the normal path on Sun’s website will land you at a registration form explaining that “Sun offers Java SE for Business, a service offering that provides Read More …

XPath Performance

XPath is usually the perfect language, providing a simple and elegant way to compute values from the content of an XML document. For example, say that you want to count the number of elements. The XPath 1.0 query for this is about as concise as it gets: 1 XPathFactory xPathFactory = XPathFactory.newInstance(); 2 XPath xPath Read More …

Something You Didn’t Know About Generics

Before the introduction of Generics in Java 5 it’s commonly known that in a class you can’t have two methods with the same signature that differ by return type alone.  More formally, the Java Language Specification §8.4.2 says that “it is a compile time error to declare two methods with override-equivalent signatures in a class”.  Take Read More …

Evaluating Excel Formulas with Apache POI

Apache POI is a full-featured Java library for reading several different Microsoft file formats, including Excel. (Note: this post only covers POI version 3.0.2-FINAL released in February 2008). POI supports evaluating cells with formulas containing Excel functions. For example, consider the code below for reading a java.util.Date from a simple spreadsheet with the formula “=NOW()” Read More …