The resultset I am obtaining from a query is TYPE_FORWARD_ONLY. And the cursor is now pointing to the last row. How can I move this cursor to the first row.(The problem is th result set is TYPE_FORWARD_ONLY).
The Problem is coming only when executing Stored Procedures. ------------------ Other Sql queries are executing nicely.
I am executing the query and the table is changed dynamically using a TableModel.
In the tablemodel following code is executed.
But the results.last(); is not getting executed.
java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
then how can I get the numrows.
IF I use
then the cursor will reach at the end. And when executed the JTable is created with java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY as content.
Any one have some idea to cure it.
The Problem is coming only when executing Stored Procedures. ------------------ Other Sql queries are executing nicely.
Before I tell you anything else. Change your screen name. You must do this because the moderators here will get upset with you if you don't. Your publicly displayed name should be Ram Mohan not Sliders Field.
You can change your display name by clicking the link at the top of the page for "My Profile" and then clicking the link for "View/Update Profile".
Anyway...
if you want a specific cursor then you need to specify it. You are specifying this for Statement but where do you do this for PreparedStatement? You have to do this for PreparedStatement too.
Like
(I edited the above to fix the layout I hope...) [ November 09, 2005: Message edited by: Maximilian Stocker ]
Sorry you said Stored Procedures and not Prepared Statements.. but same idea. Look at the method prepareCall(String sql, int resultsettype, int resultsetconcurrency)
I will look method prepareCall(String sql, int resultsettype, int resultsetconcurrency) for stored procedures.As you find I was excuting query without looking the contents. now I have to check the query stored procedure or not.
To be perfectly honest I wouldn't have an editable JTable backed by a live cursor anyway. It's kind of expensive from the DB side of things and if the user goes for lunch two bad things will/could happen. 1) Those resouces are tied up on the database and could be locked as well 2) Your connection could/should time out and then your GUI will have an unpleasant error.
It would be better to just use a forward only cursor and dump all the contents into some sort of Collection. ArrayLists are nice. Then use that Collection for your JTable.
For updates you can issue UPDATE queries providing you are selecting the primary key as part of your query.
YES I think you are right. I will update my program to store the resultset in a VECTOR and I will pass this vector to the TableModel table generation.
The truth was, I am not very much familiar with tablemodel And in a trial and error method I got it correct with above program. So changing the tablemodel by accepting vector may be a HIMALAYAN hurdle for me. But believe it comes in my way. I will TRY.