> From: Joe Laffey <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Mon, 26 Mar 2001 23:38:48 -0600 (CST)
> To: Tomcat User List <[EMAIL PROTECTED]>
> Cc: Hunter Hillegas <[EMAIL PROTECTED]>
> Subject: Re: Confusing Problem with SQL Query in Tomcat
> 
>>             pst = con.prepareStatement("SELECT * FROM artist_info WHERE
>> upper(name) = upper(?)");
> 
> Does Postgres have any equalsIgnoresCase support? If so, might be faster
> than this.

I'll have to check on this. I don't know.

> 
>>             pst.clearParameters();
> 
> 
> No need for clearParameters(). The setString will override any old
> parameters (if their were any).

Can't hurt though, can it?

> 
> 
>>             pst.setString(1, artistName);
>>             rs = pst.executeQuery();
>> 
>>             while (rs.next()) {
>>                 out.println("Is the inputted name: " + artistName + " equal
>> to: " + rs.getString("name") + "?<BR>"); //DEBUG
>>                 counter++; //DEBUG
>> 
> 
> [snip]
> 
> 
> 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...

Do column numbers start at 0 or 1? I will try changing the query and using
the column number...

> 
> You also might not want to call rs.getString() on the same column twice.
> Use a temp var instead. (The Sun docs say not to do this for "maximum
> portability." The docs also say to read columns from left to right, which
> is why I suggested SELECTing actual columns in a know order instead of
> using *.)
> 
> If you get this to work please let us know how.

Reply via email to