-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robin,

On 10/20/2009 2:18 PM, ULS Tech Support wrote:
> Let's try this again...

- From my post last week to this same question:

On 19 October 2009 at 10:46AM, Christopher Schultz wrote:
> 3. Your latest question has nothing to do with Tomcat. It's all JDBC
>    code. This is not the proper forum to ask for JDBC help.

Your use of Tomcat in this case is largely irrelevant.

If you are looking for JDBC advice, I'm still happy to provide some:

>     public Vector queryPaged4(String strTableExt) throws SQLException {
>         dbRecords.removeAllElements();

That's an interesting line of code to appear first in a method.
dbRecords... is this perhaps a shared structure? Could you be corrupting
it with your unsynchronized access to it?

>         CallableStatement call = dbConn.prepareCall("{call sp_PagedItems4 
> (?,?,?,?,?)}");

[snip]

>         if (!call.execute())//Query
>         {
>             //No ResultSets Returned;
>         } else {

This is unlike the standard idiom one typically sees for executing
prepared statements. Try this:

    rs_info = call.executeQuery();

    if(rs.next()) {
     ....

>             try {
>                 rs_info = call.getResultSet();
> 
>                 //Save the total number of records (value) in 
> queryPagedRecords
>                 queryPagedRecords = rs_info.getInt("TotalRec");

Calling ResultSet.getXXX without first calling ResultSet.next is, I
believe, an error. I suspect that your stack trace shows that the line
containing 'getInt' above is the place where the exception is thrown.

If TWFreeTDS allows this use of the API, then it is not JDBC-compliant.

>                 if (queryPagedRecords > 0) {
>                     //Test for another resultset.
>                     boolean bTest = false;
>                     bTest = call.getMoreResults();
>                     //Next resultset established, let's get the data!
>                     dbResultSet = call.getResultSet();

The documentation for Statement.getResultSet says:

"
Retrieves the current result as a ResultSet object. This method should
be called only once per result.
"

You have now called this method twice. Perhaps you should re-structure
your code.

On the other hans, you have called Statement.getMoreResults(), which may
interfere, here. Why must you call getMoreResults?

>             } catch (SQLException e) {
>                 System.out.println("SQLException: " + e);
>                 System.out.println("SQLException Message: " + e.getMessage());
>             } finally {
>                 rs_info = null;
>                 temp = null;
>                 dbResultSet = null;
>             }

You might want to close your ResultSet objects, your CallableStatement
object, etc. Otherwise, you leave yourself open to a resource leak. In
fact, for many databases, this is a guaranteed resource leak.

> I did try and modify the code to the following to see if it helped, but 
> again, i'm still stumped on HOW to retrieve the data from the resultsets.

ResultSet.getXXX ought to give you data from a SELECT query. It's not
clear how you are returning data from your CallableStatement.

The documentation for CallableStatement says:

"
IN parameter values are set using the set methods inherited from
PreparedStatement. The type of all OUT parameters must be registered
prior to executing the stored procedure; their values are retrieved
after execution via the get methods provided here.
"

I don't see any calls to CallableStatement.getXXX in your code. Perhaps
you are trying to get those from your ResultSet?

Your code is very confusing to me.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrfMr4ACgkQ9CaO5/Lv0PDQHwCdFIeMNqA6umPn4L4o4xiMkduY
G7wAoIiC9+9SSK/TVEYXKmSMsKuJ9hwR
=XgJL
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to