From: | Harry Schittler <hs(at)multimedia-werkstatt(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | getBinaryStream/setBinaryStream 7.2<->7.4 Question |
Date: | 2003-12-29 18:11:17 |
Message-ID: | 3FF06E45.70308@multimedia-werkstatt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
I just upgraded from postgres 7.2 to 7.4 (pg72jdbc2.jar to
pg74.1jdbc3.jar), after the upgrade I got some behaviour I simpy dont
understand.
For example: given the following code:
Table Bild is (int, int, bytea)
void test(Connection con) {
PreparedStatement stmt=null;
try {
stmt=con.prepareStatement("insert into Bild (bildid, filmid,
daten) values(?,?,?)");
stmt.setInt(1,100000);
stmt.setInt(2,10001);
stmt.setBinaryStream(3,new ByteArrayInputStream(new
byte[]{(byte)255, (byte)216, (byte)255, (byte)224, (byte)0}), 5);
stmt.executeUpdate();
stmt.close();
stmt=con.prepareStatement("select daten from bild where
bildid=100000");
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
InputStream in = rs.getBinaryStream(1);
int data;
while ( (data = in.read()) != -1)
System.out.println(data);
rs.close();
stmt.close();
}
stmt=con.prepareStatement("delete from bild where bildid=100000");
stmt.executeUpdate();
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
output using pg72jdbc2.jar :
255
216
255
224
0
output using pg74.1jdbc3.jar :
195
191
195
152
195
191
195
160
0
in both cases the sequence 255,216,255,224,0 is stored in the database.
As you can see, values bigger than 127 are translated to 16bit values.
Is this the expected behaviour?
cu Harry
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2003-12-29 19:25:38 | Drop support for jdk 1.1, 1.2 ? |
Previous Message | Paul Thomas | 2003-12-25 10:37:24 | Re: JDBC java.net.BindException connecting to Postgres 7.4 running on Cygwin Win2K |