Monday, August 4, 2008

Re: [JDBC] macaddr data type and prepared statements

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


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

No comments: