Monday, October 15, 2007

Quiet Time, and, how to suppress derby.log in Apache Derby

You probably won't hear much from me in the next few weeks - big deliverable. But I'll Be Back...

A quick tip from the Derby user's list, that I thought was very useful, particuarly in embedded situations where you don't want to leave detritus around when you're running Derby.

A user asks:

I'm about to distribute my java app with an embedded derby database,
but it's really not polite for apps to write unsolicited files to
disc. Anyway of suppressing the derby.log file?

Knut Anders from the Java DB team has a great suggestion:

You could take a look at the property:

If you create a stream object which swallows whatever is passed in to
its write() method and put it in a public static field in the class
MyApp, like this

public static final OutputStream DEV_NULL = new OutputStream() {
public void write(int b) { }
then you can suppress the derby.log file by setting to "MyApp.DEV_NULL".


Anonymous said...

Good tip. Note our Esteemed Host accidentally left a stray quote character in the link, so it will 404. After it does, just chop out the %22 at the end :)

Unknown said...

Thank you, Dear (Anonymous) Reader. I have fixed the %22 bug.

cbellone said...

Yes, it's true... this annoying "feature" is still included into Derby.
Many thanks for your tip! I've used it in my application:

ejisto's Main class