Monthly Archive for October, 2009

Eclipse Tips: Template for iterating ResultSet

Those who works with Eclipse and JDBC can take a gross benefit from this little template.

Simply add the template. I use as name: ‘while’, context: ‘Java statement’, description: ‘iterate ResultSet’. You can certainly change them.

while (${en:var(java.sql.ResultSet)}.next()) {
	${cursor}
}

What I love from the new iMac and what I don’t

Two days ago Apple announced a new iMac line with many new things and many to talk about. I’m quite impressed with the changes but still wondering why they don’t announced it via an Apple event. This announcement is much bigger that iTunes 9, yet for the latter, they do have special event.

So what is so lovable about the new iMac?

  • The size of the screen. Wide screen! Yet it will be useless if the resolution is standard. But they do have incredible resolution as well. I’ve been waiting for a 24 inch wide monitor with resolution of more than 1920 x 1200 and can’t find any. My 17 inch laptop has a resolution of 1920 x 1200 as well, so why the 7-inch-bigger monitors can’t have better resolution?
  • The Magic Mouse. Yes! My Mighty Mouse is always dirty and I have to clean it every week. But this mouse has no hole in the body make it impossible for dust to get in.
  • i5 and OOH… i7 processor. That’s fast!
  • A slot for SD card. Nice little gesture for that.

But it still has a lot of things I hate of. The list is even longer than the lovable things.

  • Glossy screen. Yeah… I do believe there will be 3rd party supplier with a matte solution, but why don’t you make it as an option, Apple?
  • The graphic card. Why oh why you don’t put an NVIDIA card to all iMac? More specifically, why don’t you put an NVIDIA card in the 27 inch iMac? It just means that there is no OpenCL in that computer, right?
  • Expansion possibility. No way to insert your own harddrive. You just stuck with what you order, that is 1 TB or 2 TB.
  • No option for Solid State Drives. Why a MacBook Pro can have SSD and iMac not?
  • Only one Firewire 800 port? With no option for harddrive expansion, using Firewire 800 for that matter is quite obvious solution. But if you only have one Firewire 800 port, where will you put your other devices (A CF reader, for example)?
  • No USB port on the keyboard. Quite obvious and the one you can expect from a wireless keyboard.
  • Batteries for the mouse and the keyboard. Oh my! So far for a better environment (and thicker wallet).
  • No Bluray? I don’t know what’s between Apple and Bluray.
  • The monitor is fixed. You can’t set the height of it and you can’t put it vertically. Yes you can hang it in the wall but then what? You have to crawl to insert a DVD disc.

That’s it! The new iMac is good, but not excellent.

Websphere Application Server Community Edition (WAS CE) and PostgreSQL

Setup a PostgreSQL Data Source on WASCE is pretty straight forward. The only problem is on the beginning where we have to put the JDBC driver in the correct location.

First, you need to download the PostgreSQL JDBC jar. If you want, you can get it using Application Stack Builder that PostgreSQL included in the package.

I have two JARs, one for JDBC3 and one for JDBC4. The names are postgresql-8.4-701.jdbc3.jar and postgresql-8.4-701.jdbc4.jar. Copy these files and put them under WASCE repository directory: /postgresql/postgresql-8.4/701.jdbc3/ and /postgresql/postgresql-8.4/701.jdbc4/ respectively.

Restart the websphere and open the console. You should see both JARs under Repository page.

2009-10-21_1210

Now it’s time to prepare the Data Source. Go to Database Pools in the Adminitration Console and create a new db pool using ‘Using the Geronimo database pool wizard’.
2009-10-21_1214

Give appropriate name and select PostgreSQL as the database type. Click ‘Next’.
2009-10-21_1215

Now put the database access information and deploy it.

If you open the database pools page one more time, you should get your database pool there.
2009-10-21_1217

That’s it, you can click ‘Usage’ to get information how to use your database pool from the web application. However, if you are using Eclipse, I can explain a better way to go through the stuff, but maybe later…

Using Eclipse WTP for developing application under Websphere Application Server Community Edition (WAS CE)

This tutorial assumes that you already have Eclipse WTP (Galileo) and WAS CE (2.1) installed correctly. To make sure that your Websphere is installed correctly, start the server and go to the console. If you can do so, you’re in the right track. After that, just shutdown the server because we will manage the server from Eclipse.

After that, the first step is to install the Eclipse plugin for WAS CE. This plugin contains several things, and one of it is WTP server adapter for WAS CE. The update site for the plugin is http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/

Restart Eclipse like usual after installing the plugin.

Now we are ready to develop our first project under WAS CE. Create a new ‘Dynamic Web Project’. You’ll get something like this:

2009-10-20_1235

What’s important here is to change the Target runtime to ‘IBM WASCE 2.1′, so if you haven’t had one, you should create a new target runtime by clicking the ‘New…’ button. I think the creation of target runtime is pretty self explanatory. You just need to put the directory name of where you installed the WAS CE. This step is critical because if you don’t change the Target runtime now, the application can’t be run correctly from Eclipse.

After that, you will be asked to put the usual information for a dynamic web project but if click next and next, you will get a custom ‘Geronimo Deployment Plan’. Here you need to put the name of group id, artifact id, version, and artifact type. This information is needed because your application will be seen like a normal system resource, which can be a library or an web application.

2009-10-20_1241

After that you will get a new web project. What’s different in this web project is there is a geronimo-web.xml under WEB-INF and IBM WASCE 2.1.will added as referenced library.

You can start developing your web application and running it using normal way.

Eclipse RCP Tips: Drawing dash line

To draw a dash line on Eclipse you can use the API on GC:

setLineStyle: Sets the receiver’s line style to the argument, which must be one of the constants SWT.LINE_SOLID, SWT.LINE_DASH, SWT.LINE_DOT, SWT.LINE_DASHDOT or SWT.LINE_DASHDOTDOT.

If you need a custom dash line, then you can do it by defining the sequence using method setLineDash. This method receives an array of int which defines the length of rendered line and the length of blank line.