From: | keshava <keshava(dot)koushik(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Postgres 9.3 JDBC issue with reading bytes |
Date: | 2014-07-01 07:43:38 |
Message-ID: | CAApVkt9OGhQpUosAqf4oSm5aNc698Ej0Gn=JNH7KCAjqe1w2dA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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(at)106bdde4"
however the one got from DB looks like [B(at)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
From | Date | Subject | |
---|---|---|---|
Next Message | Elizabeth Chatman | 2014-07-02 20:09:40 | NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs |
Previous Message | Kris Jurka | 2014-06-28 00:38:16 | Re: Suspected JDBC bug |