Apache POI, translating Excel column number to letter

Recently I had to write some code to generate excel files using Apache POI. One of the files was fairly complex and used formulas in a few cells.

I found myself spending a few hours searching for a way to translate the indexed column numbers that POI uses to the column letters I needed in those formulas.

It turns out the solution is quite simple, you just have to use org.apache.poi.hssf.util.CellReference:

String columnLetter = CellReference.convertNumToColString(columnNumber);

Enabling remote JMX on Glassfish 2.1.1

The default glassfish app. server installation comes with local JMX connections enabled by default.

To enable JMX connections from remote hosts all that’s needed is to add -Djava.rmi.server.hostname=<hostname> in the JVM Options of the instance of GlassFish, where <hostname> is the external hostname of the server where glassfish is running.

Java Threading and Concurrency Introduction

Multi Threading is one of the most interesting subjects when developing applications, be them in Java or any other Language: The ability to have ones software performing multiple tasks at the same time, maybe handling multiple requests from users, parallel processing things… wicked stuff really!

On the other hand… when things go wrong with multi threading, they go wrong really fast, they go wrong all over the place, it is hard to debug (specially if threads “share” stuff) and you get the usual comment: “I just don’t get it why this is doing this”. Multi Threading is not without challenges!

In this Tutorial we’ll be going through a bit of theory regarding threads and the Java memory model, but I’ll try to make it as interesting as I can with examples and demonstration of concepts. We’ll see how stuff can go wrong, how to avoid those situations, and we’ll play with threads just to see them working! A more advanced tutorial will follow(at some point) in which I’ll discuss more advanced parts of Threads and Concurrency.

Read more of this post

JPA 2 Tutorial – Relationships – One To Many

Following from the previous tutorial we now dive into move interesting and complex parts of JPA 2: Relationships! In this tutorial we’ll be focusing on One-to-Many relationships (mainly Bidirectional), looking into their particularities (specially related to the Cascading of operations), we’ll create a JUnit Test class for testing the Relationship, look at what actual SQL queries that are performed, learn by example and also some more interesting theory that is related to all of this. Read more of this post

Getting Started with JPA 2 Tutorial

So, one of the most common comments I get to hear while at work almost every week regarding JPA is : “Oh I Just hate JPA!” . I never really had much of a problem with it, obviously sometimes with JPA something just doesn’t want to work for some strange reason and the Logs don’t really help finding the problem but most of the days everything works fine.

At some point I decided that I would write a few tutorials on JPA. Some time has passed since and now I’m actually doing it. Use the comments section for corrections if you find any problems or errors, or if you would just like to leave a kind word!

Read more of this post