Archive for the 'java' Category

Adding Plugins to Ibator

Saturday, February 20th, 2010

Ibator (formerly knows as ‘Abator’) is an invaluable code generator to create all necessary code to access database tables with the (also pretty invaluable) Java OR framework Ibatis.
Ibator creates a variety of SQL code to easily build here-clauses to acces your tables. The one thing that is missing is support for the SQl “limit” clause which is offered by Mysql and other popular databases.

A guy called harawata has created a plugin for Ibator, which creates code to easily add “limit” clauses to your db-calls. Thank a lot for this (once again invaluable) tool! You might also want to check out his other plugins.

Ok, so now how to add these Plugins to the code generator? You need to compile the classes with ibator.jar in the classpath.

Then enable the Plugin in your ibatorConfig.xml file within the <ibatorContext>:

<ibatorPlugin type=”AddLimitClausePlugin”></ibatorPlugin>

Finally add the resulting Plugin-file to the classpath when calling Ibator:

java -cp ibator.jar:limit.jar org.apache.ibatis.ibator.api.IbatorRunner -configfile ibatorConfig.xml -overwrite

Of course this will also work when starting Ibator from an ant file.

Hassle-free date formatting in Java

Monday, July 2nd, 2007

Are you a Java programmer and always hated it to handle Dates, Calendars, DateFormatter and the kind just to display a simple and small java.util.Date correctly?

One again the Apache commons library comes to a rescue! Programmer’s little helper in this lesson is the FastDateFormat class. Just instantiate a n object , pass your desired Locale and you are ready to format any Date with date and/or time to your wishes. Either you use the built-in formattes “SHORT, MEDIUM, LONG, FULL” or pass a custom pattern.

Here’s a little example:

import org.apache.commons.lang.time.FastDateFormat;
FastDateFormat df = FastDateFormat.getDateTimeInstance(
FastDateFormat.SHORT, FastDateFormat.SHORT, Locale.US);
System.out.writeln(df.format(creationdate));

FastDateFormat has a lot of initializers and functions to format your date and time values for your needs. Make sure to check out more classes of the org.apache.commons.lang package, that holds a lot of gems which make a java programmer’s day much easier.

übrigens: hashmap…

Monday, January 8th, 2007

Übrigens: HashMap ist keine Karte von Amsterdam!

Arrogantes Deployment

Thursday, October 26th, 2006

Unglaublich, was sich Ant manchmal einbuildet…

Java und Objekte

Thursday, July 13th, 2006

Es sagte die String Variable zum Programmierer: “Du behandelst mich wie ein Objekt!”