PreparedStatement and TYPE bit

From: Ingmar Lötzsch <iloetzsch(at)asci-systemhaus(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: PreparedStatement and TYPE bit
Date: 2006-11-28 09:15:12
Message-ID: 456BFE20.8010400@asci-systemhaus.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hallo,

how can I use PreparedStatement to insert or update columns of type
bit(n), varbit, ...?

I have never figoured out the right way. In former versions of the
JDBC-Driver I used setString() as shown below or constructed the whole
query string and used Statement.

String sql =
"...
WHERE f1.verkehrstage & B? <> 0::bit(384)
...";

PreparedStatement pstmt_select1 = con.prepareStatement(sql);

BigInteger mybits = ...

// padding bits 0 on the left up to 384 (type bit(384))
String querybits = mybits.or(this.bit384).toString(2).substring(1);

pstmt_select1.setString(1, querybits);
...
ResultSet rs = pstmt_select1.executeQuery();

This does not work in versions 8.x.

Thank you

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Michael Paesold 2006-11-28 09:33:00 Re: Postgres Server collapse
Previous Message Jim Nasby 2006-11-28 03:02:27 Re: Backup with Java