... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)


Starting Oracle on Windows

Under Windows, to configure an Oracle instance to start automatically when its service starts, make sure that the following registry key is set:


where ID is the identification number of the Oracle home (typically '0') and INSTANCE is the name of the instance.  The corresponding service will be named 'OracleServiceINSTANCE'.

Also note that it is generally a bad idea to stop and Oracle instance by simply stopping the service.


Growing Java Arrays

Here is a Java convenience method to append an element to an array (of any kind):

private static <T> T[] appendToArray(T[] array, T element) {
    T[] newArray = (T[])Array.newInstance(array.getClass().getComponentType(), array.length + 1);
    System.arraycopy(array, 0, newArray, 0, array.length);
    newArray[array.length] = element;
    return newArray;

Hacking SVN Logs

I wrote a little Windows batch script, svnloghack,  that makes it easier to change the revision logs in a Subversion repository.  It takes a path to a subversion repository and a list of revision numbers as command line arguments.  It creates a file named zsvnhackrev.txt for each revision (where rev is the revision number).  Each file contains the corresponding log message.  It also creates a batch script named zsvnhack.bat that writes back all of the log messages to their corresponding revisions in the repository (presumably after you have edited them).

Also, the batch script pre-revprop-change.bat is a minimalist hook script for Subversion that will permit log changes (and other revision property changes) to take place.  You have to put it in the hooks directory of the repository if there isn't such a hook already there.


JUnit Tear-down Assertions

In JUnit 4.1, if an assertion failure occurs in a tear-down method it will mask any failure that occurred in the test case itself.  There is no real work-around for this problem other than commenting out the assertion in the tear-down method.


Offline Web Reading

A decent set of options for WGET to suck down web pages for offline reading is:

wget -r -l 0 -k -p -L -np -nv http://somesite.com/index.html

Adjust the -l option to taste (number of levels to descend, inf for infinity).


Time and Date

The web site http://www.timeanddate.com/ is a useful resource for, well, time and date information.  In particular, it has the niggling details about when different jurisdictions change to daylight savings (a pertinent topic with the North American DST change this year).


The Eclipse AspectJ development tools (1.4.1) seem to be finicky when it comes to applying changes to aspects.  If you uncomment a declare warning, for example, the change will not be noticed and will not trigger a rebuild even after you save the file.  You must make a more substantial change elsewhere in the aspect file.  Also, the builder seems to ignore changes to all aspect files after you add AspectJ nature to a Java project .  I found myself having to do manual cleans to get my AspectJ changes to take.

The Compiler is Your Friend

Strong typing has a bad rap these days.  Someday (read: never), I will have to write an article about how it is not evil.  Especially since strong typing was a big part of what made me "downgrade" from Lisp to Java.

Yesterday, I spent a couple of hours sweeping through our "application in crisis".  Being a Java application that uses RCP and Hibernate, there was a lot of run-time type checking going on.  Unnecessarily, I might add.  By declaring the real types of objects (instead of just Object), the compiler dutifully found a bunch of bugs that would have taken a whole lot of testing, or customer deployment, to find.  Bugs like: confusion over whether an entity's key was scalar or composite; using the wrong return type for a query; diverging from the mandated equals/hash code strategy; or trying to persist non-persistent objects.  All found at the cost of a few minutes of adding appropriate declarations.


JDBC Statement Types

The JDBC API says that CallableStatement extends PreparedStatement that extends Statement.  This suggests that CallableStatement can do everything that PreparedStatement can do, and more (just as PreparedStatement has a superset of Statement functionality).  Well, O-O principles suggest this (viz "extends"), but the documentation leaves room for doubt.  It says that CallableStatement is intended for use to call stored procedures.  Of course it is, except that the wording suggests that that is all it should be used for.  So I wrote a quick program that used the ODBC bridge to see whether I could run a simple query through a CallableStatement.  It worked, and I thought my paranoia unjustified.  Until I tried the same thing with the jTDS driver.  It didn't work, complaining about a syntax error at the keyword SELECT.

Transactions in Hibernate

If you are borrowing the connection from Hibernate (a questionable practice, to be sure), then be aware that JDBC Connection transactions are much faster than Hibernate Session transactions.  In our application, Session.getTransaction().commit() took almost a second when stepping over it in the debugger -- and that is when the only work done was a query.

Blog Archive