Application Server Solutions for Microsoft IIS and ASP.NET
       solutions   products   partners   company   support   downloads         store
ServletExec Self-Help: FAQ
Back to Search >  Back to Search Results

Faq ID 154
Product JTurbo
Category Statement
Question I got a Statement from a Connection object and then called setMaxRows() on the Statement Object. It works fine, but now every Statement I get from that same Connection Object has the same max row setting so my ResultSets are missing some rows. What is wrong ?
Answer This problem was fixed in all versions of JTurbo 3.x.
When you call setMaxRows(n) on a Statement Object, JTurbo was sending the following message to SQL Server:
set rowcount n
This causes SQL Server to only return n rows for all queries made using that same Connection [thus reducing network traffic which is the main idea behind using setMaxRows() in the first place ].
There are a few workarounds to this problem.
  1. Get JTurbo 3.x or newer which corrects this problem
  2. Do not call setMaxRows.
    Instead modify your query so that it uses the TOP command like this:
    Select top 200 * from myTable
  3. After you call setMaxRows(n), and after you get back the limited ResultSet that you need, but before you call stmt.close(),
    call setMaxRows(0) to set the Statement (and thus the underlying Connection) back to an unlimited number of rows.

Note: workaround #2 is especially important if you are using Connection Pooling.

Note: Readers of this FAQ may also find FAQ #82 to be of interest.



   
company media information terms of use privacy policy contact us