• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resultset + TYPE_FORWARD_ONLY problem

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Friends,

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.

Ram Mohan.
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ram,

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 ]
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry you said Stored Procedures and not Prepared Statements.. but same idea. Look at the method prepareCall(String sql, int resultsettype, int resultsetconcurrency)
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Sliders Field"
Max is correct. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
 
Ram Mohan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankx

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.

But still I don't know how to do that validation.

Keep in touch.

Ram Mohan.
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ram,

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.

Anyway I think that is a better route to go.
 
Ram Mohan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


Ram Mohan.
reply
    Bookmark Topic Watch Topic
  • New Topic