Hi all, I'm fairly new to java and I'm having problems with a project in Netbeans I'm working on.

I would like to keep a register of the options chosen by people when doing a query on a website. To do that, I added a small table with a counter field. The counter should be updated on the options chosen everytime someone makes a new query. So in my project, on the data layer, I do this to retrieve the value of a counter:

consultCont = "select counter " +
"from CounterEn " +
"where category = '"+categories[i]+"'";


con = this.conn();

st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);

rs = st.executeQuery(consultCont);

cont = rs.getLong("counter")+1;


}catch (Exception e) {

Now, when it gets to the rs.first() part it gives this exception:

>Method "first" in class "com.microsoft.sqlserver.jdbc.SQLServerResultSet" threw an exception: instance of com.microsoft.sqlserver.jdbc.SQLServerException(id=249)<

If I comment out the rs.first() part the rs.getLong part gives me this:

>Method "getLong" in class "com.microsoft.sqlserver.jdbc.SQLServerResultSet" threw an exception: instance of com.microsoft.sqlserver.jdbc.SQLServerException(id=253)<

I have tried using several combinations calling the methods but the problem persists. The strange part is that it doesn't say exactly what the exception is about and the exception id keeps changing. Also I've tried the call directly on the SQL Server and it works fine.

I have looked in several forums and websites but I haven't found a good reason as to why this is happening and now I'm a little fed up with it. I guess it has to do with how I'm managing the result set but I have no idea what I'm doing wrong.

Any ideas will be very appreciated.

Thanks in advance.