Re: macaddr data type and prepared statements

From: Kris Jurka <books(at)ejurka(dot)com>
To: Steve Foster <s(dot)p(dot)foster(at)leeds(dot)ac(dot)uk>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: macaddr data type and prepared statements
Date: 2008-08-05 05:30:39
Message-ID: Pine.BSO.4.64.0808050129200.411@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Mon, 4 Aug 2008, Steve Foster wrote:

> I'm trying to bulk load some MAC addresses using a prepared statement. But I
> keep on getting an error about incorrect datatype (complains that I'm trying
> to insert "character varying"). Bellow is an example of the code that I'm
> using:
>
> stmt.setString(3, line[2]);
>

Don't use setString for non-string types. With a recent JDBC driver you
should use setObject(3, line[2], Types.OTHER);

Kris Jurka

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Steve Foster 2008-08-05 08:46:05 Re: macaddr data type and prepared statements
Previous Message Oliver Jowett 2008-08-04 20:20:18 Re: macaddr data type and prepared statements