Re: ERROR: operator does not exist: integer = character varying

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Andreas Berglund <email(dot)lists81(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: operator does not exist: integer = character varying
Date: 2012-02-11 16:25:44
Message-ID: CABUevEwFNEJNC86dY=d77jfcG0x2Nysu63FVOgwS8CdE_gNJPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Feb 11, 2012 at 17:22, Andreas Berglund <email(dot)lists81(at)gmail(dot)com> wrote:
> Hi!
>
> I have the following piece of jdbc code
>
> String query = "UPDATE books SET title = ? WHERE book_id=?";
> pstmt =conn.prepareStatement(query);
> pstmt.setInt(1, new_book_id);
> pstmt.setString(2, getStringPrompt("new title"));
> pstmt.executeUpdate();
>
> getStringPrompt returns a string and new_book_id is an int.

Aren't you passing your parameters in the wrong order? Your query
wants title first and book_id second, but you send in new_book_id
first and the new title second?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Terry Lee Tucker 2012-02-11 16:53:15 Re: question on trigger
Previous Message mgould 2012-02-11 16:22:44 question on trigger