-
Problem with sql result set in netbeans project
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]+"'";
try{
con = this.conn();
st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = st.executeQuery(consultCont);
rs.first();
cont = rs.getLong("counter")+1;
rs.close();
}catch (Exception e) {
e.printStackTrace();
}
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.
Similar Threads
-
By mahalirajesh in forum Database
Replies: 2
Last Post: 05-13-2008, 10:10 AM
-
By Spumbu1977 in forum VB Classic
Replies: 2
Last Post: 09-07-2006, 08:56 PM
-
By ObiWan in forum VB Classic
Replies: 3
Last Post: 05-23-2006, 10:35 AM
-
Replies: 4
Last Post: 04-13-2001, 03:31 AM
-
By Adam Dawes in forum VB Classic
Replies: 3
Last Post: 12-21-2000, 11:50 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks