• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Current value for Resultset..

 
Bhardwaj Shweta
Ranch Hand
Posts: 36
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

i want to navigate thorugh my code in servlets..If i want to code for previous Button,first i need to move my cursor to current record so that user can move to previous record..

but i am not getting how to move to current record.my cursor is set on second record and rs.first() only returns boolean value..
Please tell me some function for rs.currentrecord()...
Thanks
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's true that return type of method is boolean. Reason is the method tries to move the record pointer to the first record, if the recrodset has any record it will return true or else false. So after calling rs.first(), if you get true value, you are pointed on the first record. Now if you retrieve column values from here, you will get the values of first record.
 
Bhardwaj Shweta
Ranch Hand
Posts: 36
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey swastik thanks for your reply,but what about moving to current record..in case of previous how can i move my cursor to current record.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shweta

I could not get your query very clearly. What exactly do you mean by current record? Once a recordset is created the pointer is typically before the first row. Calling next takes you the next row, calling previous takes you to the previous row. Apart from these you have methods like first,last,relaive,absolute etc. So, what exactly do you mean by current record. Could you please elaborate a more?
 
Bhardwaj Shweta
Ranch Hand
Posts: 36
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you provide me the logic for traversing previous records.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is going wrong with your code?
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, as much as I understood probably your code is taking you the first record, correct me if I am wrong. But probably you wish to move to the exactly the previous record from the current record, right? Moreover as because it's a servlet application, every time the request goes, the pointer is pointed before the first row, right?
 
Bhardwaj Shweta
Ranch Hand
Posts: 36
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eggjacktly Thats my problem
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And as because it's a servlet application, every time the request goes, the pointer is pointed before the first row, right?
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rs.absolute(row). There's also a relative method that moves the cursor forward or backward a number of records. Swastik already mentioned these.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's true Rob, but probably we need to retain the last positioned row in session, correct me if I am wrong?
 
Bhardwaj Shweta
Ranch Hand
Posts: 36
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
true
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And when the next request comes, retrieve the value from session, and call absolute(retrieved value from session-1), right?
 
Bhardwaj Shweta
Ranch Hand
Posts: 36
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys
let me try this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic