Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

:confused: How to call sql cursors in java ??? Urgent Plz. help...

 
VS Prapoorna
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
Can any body help in getting an idea to call a sql cursor using java code..
i have searched for this but i could not find it.. so plz. help me in this regard asap.
Thanks in advance,
Sarada
 
Barron Greig
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you have a Connection object "con", you can create statement, e.g.
PreparedStatement stmt = con.prepareStatement("SELECT * FROM EMPLOYEES");
executing that statement returns a ResultSet which you can then iterate over. I guess the ResultSet is probably using a cursor somewhere deep down in the implementation
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
.. rs.getXXX methods to retrieve field info from
each ResultSet result.
}
 
VS Prapoorna
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i know that
a ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next() method moves the cursor to the next row (similar to an iterator or an enumerator in Java).
But my problem is ...when i write a cursor in a database with some name MyCursor.sql i wanted to call that cursor in side my java code .....so this is the actaul problem...i wnt some help from any body.
Thanks in advance,
Sarada
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic