Обсуждение: Postgres 9.3 JDBC issue with reading bytes

Поиск
Список
Период
Сортировка

Postgres 9.3 JDBC issue with reading bytes

От
keshava
Дата:


Hi all,
I am trying to migrate my java application from PostgreSQL 8.4 to latest release.
I am facing an issue with reading the byte data from the db.
I am inserting the IpAddress in bytes in to the table and trying to reconstruct it back in a different process. but while reconstruction i could see and extra '/' character 
here is what exactly i am doing. 

    stat = con.prepareStatement("insert into IPADDR(IP_ADDR, LSVR_ID) values(?, ?)");
    InetAddress iaddr = InetAddress.getLoopbackAddress();
            stat.setBytes(1, iaddr.getAddress());
                stat.setInt(2, ID);
                stat.executeUpdate();

and read it back like this 

    stat = con.prepareStatement("select IP_ADDR  from IPADDR");

when i print the bytes before inserting and after retrieval i could see that they are not same.
for local loopback address which is 127.0.0.1 before inserting its 
"[B@106bdde4"
however the one got from DB looks like [B@6d7eaa83  when i construct string out of it 
it shows additional '/' character ==>"/127.0.0.1"
can anyone please help in resolving this issue


Best regards  :)
keshava Hosahalli