Scrollable result set

Source: Internet
Author: User
Network Digest "rolling feature:

Next (). This method moves the cursor to the next record.

Previous (). This method can move the cursor to the previous record, provided that there are records before it.

Absolute (INT row), you can use this method to jump to the specified record location. True is returned for successful positioning. False is returned for unsuccessful positioning. If the returned value is false, the cursor is not moved.

Afterlast (), the cursor jumps to the last record.

Beforefirst (), before the cursor jumps to the first record. (Jump to the cursor initial position)

First (), the cursor points to the first record.

Last (), the cursor points to the last record.

Relative (INT rows), relative positioning method, the parameter value can be positive or negative, the parameter is positive, the cursor moves down the specified value from the current position, the parameter is negative, the cursor moves the specified value from the current position up.

Type_forward_only, which indicates the type of the resultset object that the pointer can only move forward.

Type_scroll_insensitive, which indicates the type of the resultset object that can be rolled but is not affected by other changes.

Type_scroll_sensitive, which indicates the type of the resultset object that can be rolled and normally affected by other changes.
Application:

  1. Public concurrentincluqueue getstockinfoqueue (string table, string stockcode) {// retrieve the stock information from the database, save it to the queue, and return to the queue
  2. Concurrent1_queue <rtmm> CLQ = new concurrent1_queue <rtmm> ();
  3. String SQL = "select * from" + Table + "where s_code = '" + stockcode + "'";
  4. String sql2 = "select count (*) from" + Table + "where s_code = '" + stockcode + "'";
  5. Try {
  6. Statement stmt = con. createstatement (resultset. type_scroll_insensitive, resultset. concur_read_only); // you can scroll the result set.
  7. Resultset rs2 = stmt.exe cutequery (sql2 );
  8. Rs2.last ();
  9. System. Out. println ("number of records" + rs2.getint (1 ));
  10. Int records = rs2.getint (1); // obtain the number of records.
  11. Resultset rs = stmt.exe cutequery (SQL );
  12. If (records <60 ){
  13. While (Rs. Next ()){
  14. String code = Rs. getstring (1 );
  15. String time = Rs. getstring (3 );
  16. Double open = Rs. getdouble (4 );
  17. Double Close = Rs. getdouble (5 );
  18. Double Low = Rs. getdouble (6 );
  19. Double High = Rs. getdouble (7 );
  20. // Rtmm (string code, string DT, double low, double open, double close, double high)
  21. // System. Out. println (code + time + OPEN + "" + close + "" + high );
  22. Rtmm = new rtmm (code. Trim (), time. Trim (), low, open, close, high );
  23. CLQ. Add (rtmm );
  24. }
  25. } Else {
  26. Rs. Absolute (records-60 );
  27. While (Rs. Next ()){
  28. String code = Rs. getstring (1 );
  29. String time = Rs. getstring (3 );
  30. Double open = Rs. getdouble (4 );
  31. Double Close = Rs. getdouble (5 );
  32. Double Low = Rs. getdouble (6 );
  33. Double High = Rs. getdouble (7 );
  34. // Rtmm (string code, string DT, double low, double open, double close, double high)
  35. // System. Out. println (code + time + OPEN + "" + close + "" + high );
  36. Rtmm = new rtmm (code. Trim (), time. Trim (), low, open, close, high );
  37. CLQ. Add (rtmm );
  38. }
  39. }
  40. } Catch (sqlexception e ){
  41. E. printstacktrace ();
  42. }
  43. Return CLQ;
  44. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.