getBinaryStream/setBinaryStream 7.2<->7.4 Question

Поиск
Список
Период
Сортировка
От Harry Schittler
Тема getBinaryStream/setBinaryStream 7.2<->7.4 Question
Дата
Msg-id 3FF06E45.70308@multimedia-werkstatt.com
обсуждение исходный текст
Ответы Re: getBinaryStream/setBinaryStream 7.2<->7.4 Question  (Kris Jurka <books@ejurka.com>)
Список 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




В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Paul Thomas
Дата:
Сообщение: Re: JDBC java.net.BindException connecting to Postgres 7.4 running on Cygwin Win2K
Следующее
От: Dave Cramer
Дата:
Сообщение: Drop support for jdk 1.1, 1.2 ?