Mork or what?

Posted by Mike Haller on Tuesday, December 26. 2006 at 00:00 in Java
There is a rather funny database format used in some popular Mozilla applications called Mork. The lexical proximity to the word dork is probably not intended, but who knows.

A project has been started which has it's goal to provide a Java implementation which can parse Mork database files. The thingy is called jMork - a Java Mork implementation.

It's in a very early stage but can already be used to read in Thunderbirds address books.

Why i talk about Mork ... i wanted to import some contacts and already integrated a billing software based on paradox. I managed to use an evaluation driver of a Paradox JDBC driver which worked perfectly. I only needed it once, so I guess the evaluation license is ok for such usage.

Now I also want to import my contact from Thunderbird and I wondered whether I could directly use the internal text file format. After some google queries, it became clear that the text format is ... other than expected.

After some reading of the specification of the Mork format at Mozilla's archive site, i began implementing a Mork parser. Hopefully this will be useful to anybody who ever wants to fiddle with such files.

By the way, the format is also used for the history.dat file of Firefox and looks like this:
// <!-- <mdb:mork:z v="1.4"/> -->
< <(a=c)> // (f=iso-8859-1)
  (B8=Custom3)(B9=Custom4)(BA=Notes)(BB=LastModifiedDate)(BC=RecordKey)
...
  [24(83137)(84138)(^85=)(^86=)(87139)(^88=)(8913A)(8A13A)
    (^8B=)(^8C=)(^8D=)(^8E=0)(^8F=0)(^90=)(^91=)(^92=)(^93=)(^94=)(^95=)
    (^96=)(^97=)(^98=)(^99=)(^9A=)(^9B=)(^9C=)(^9D=)(^9E=)(^9F=)(^A0=)
...
@$${6D{@
<(157=4597c727)>[9:^80(BB157)]
@$$}6D}@


Some bloggers hate the author of the format for his "genuine" ideas, others are mature enough to not comment on it at all. However, in modern times, XML would have been choosen anyway.

Useless JUnit Tip #327

Posted by Mike Haller on Monday, December 25. 2006 at 00:00
My today's useless tip is for Eclipse/JUnit. Sometimes, while developing, i'd like to test-drive my class. In former times, developers have often used the main() method, and often forgot about them. So there are some applications out where with a lot of not-intended main entry points.

My genuine idea is to use JUnit and Learning Tests for this kind of code. Usually, you create a TestCase for your class-under-test and write tests which prints out stuff to just find out how something works. Now, you can embed a TestCase as inner class into its class-under-test like this:

public class Bar {
    // Your code here ...
    public class BarTest extends TestCase {
        public void testCreate() throws Exception {
            new Bar();
        }
    }
}


The problem with this approach is, then you hit Alt-Shift-X and T to run the TestCase in the JUnit Runner, it will probably fail with the error message "Class X has no public constructor TestCase(String name) or TestCase()":


The fix for this is rather easy: Make your TestCase static:
public class Bar {
    // Your code here ...
    public static class BarTest extends TestCase {
        public void testCreate() throws Exception {
            new Bar();
        }
    }
}

Oracle sucks once again

Posted by Mike Haller on Sunday, December 24. 2006 at 00:00 in Java
If you are using iBatis SqlMaps and execute a stored procedure, you should probably not format the SQL string, e.g.:

<procedure id="exec" parameterClass="org.example.Param">
 {
      call p_main (
              #param1:NUMERIC#,
              #param2:DATE# )
 }
</procedure>


java.sql.SQLException: Non supported SQL92 token at position: 4:
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
        at oracle.jdbc.driver.OracleSql.handleToken(OracleSql.java:1165)
        at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:1064)
        at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:984)
        at oracle.jdbc.driver.OracleSql.getSql(OracleSql.java:312)
        at oracle.jdbc.driver.OracleSql.getSqlBytes(OracleSql.java:557)


The solution: remove TABS and newlines from the SQL in the procedure call.

About

My name is Mike Haller and I'm a software developer and architect at Bosch Software Innovations in Germany. I love programming, playing games and reading books. I like good food, making photos and learning and mentoring about the craftsmanship of commercial software development. Stack Overflow profile for mhaller

Quicksearch