In my application I insert data in database using C code, since the strings I receive from an untrusted source I have escaped them using
PQescapeByteaConn of libpq library. Which is working perfectly fine i.e. results in Octet format String. See below example,
Input String :
Output String :
Output String is inserted in the database. Now I retrieve that data from the database in a java code using JDBC. How I can unescape the string back to its original value ?
I thought of two possible approaches,
- Change the database retrieval query and pass this field to any String manipulation function of postgres i.e. which can convert bytea to text.
- Do the decoding in Java code.
I can understand that the approach 1 will be more efficient. I have tried almost all the functions listed here but nothing is working. Please Help!!
I am using version 8.4 of postgres on a linux machine.