Hey – It's just a rowCount()

Java is a cool language, everything in the bag – but you have to search a lot for some simple tasks. Just like what I was doing few minutes ago. These days I am learning J2EE, specially JSP, Struts etc… I was searching how to find out the count of rows in a resultset which is returned by a statement. But unfortunately I found these is no builtin property/method to find it out. However, after searching in net for a couple of minutes I found the following solution

Statement st =
   conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE,
               ResultSet.CONCUR_READ_ONLY);
ResultSet rs =
   st.executeQuery("SELECT * FROM employee WHERE id_emp LIKE '1%'");
rs.last();
count = rs.getRow();
rs.beforeFirst();

————————————————————-
Down the way, where the nights are gay,
and the sun shines
daily on the mountain top,
I took a trip on a sailing ship,
and when I reach Jamaica I made a stop.

But I’m sad to say,
I’m on my way,
won’t be back for many a day.
My heart is down,
my head is turning around,
I had to leave a little girl
in Kingston Town.
———————-
By – Harry Belafonte [Kinston Town]