> From: Joe Laffey <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Tue, 27 Mar 2001 00:07:44 -0600 (CST)
> To: Tomcat User List <[EMAIL PROTECTED]>
> Subject: Re: Confusing Problem with SQL Query in Tomcat
>
>> Can't hurt though, can it?
>
> Don't think so, but why make extra method calls ;-)
Good point.
>
>>>
>>> My guess is that it has something to do with the
>>> rs.getString(java.lang.String) call. Try rs.getString(int) instead to
>>> narrow it down. (The int is the column number. I would highly suggest
>>> doing something like "SELECT name, column2, column3, FROM <table> WHERE
>>> <whereclause>" instead of doing "SELECT * ...". If all you want is the
>>> name then only SELECT that.
>>
>> You think? The counter isn't getting incremented at all, suggesting that
>> rs.next() is evaluating to false, thus suggesting the query is returning 0
>> rows...
>
> Hmmm... My bad. I should have read that part of your note more carefully.
> Now I am a little confused...
>
> You tried pasting a plain SELECT string with no "?"s in the
> prepareStatement string? Are you certain that the connection pool works
> right? Try it with a plain connection that you establish right there in
> the code perhaps.
The connection pool works in other parts of the same servlet... I'll have to
try without it.
>
> What happens when there is more than one row in the DB that matches your
> WHERE clause? Then does it work? if so, is it mssing one row, or complete?
Haven't tested this yet. I will try this now.
>
> Is it possible that you have a non-committed transaction from a command
> line client that is holding up this SELECT with a lock? (It should give an
> exception.) Do you not see an exception? If not, are you sure your
> exception reporting code works right?
I'm not using transactions in this app... I don't think so...
>
> Here is an interesting quote from the Sun docs on ResultSet:
>
> " The column name option is designed to be used when column names are used
> in the SQL query. For columns that are NOT explicitly named in the query,
> it is best to use column numbers. If column names were used there is no
> way for the programmer to guarantee that they actually refer to the
> intended columns."
>
> This might explain not being able to get the data, but it doesn't seems to
> explain why the rs.next() would be false.
Interesting...
\>
>
>>
>> Do column numbers start at 0 or 1? I will try changing the query and using
>> the column number...
>>
>
> For some reason they start at 1. Note that this should be faster than the
> string anyway.
Thanks. I'll try these suggestions and let you know how it turns out...
Hunter