0

I have one table that has 2 fields one(container_id) for numeric type and another for byte type(coDearntainer_objects) . I would like to read the byte field(container_objects) as a string for corresponding (container_id) field.

How could I do this? I am using Postgresql Db Table Structure:

CREATE TABLE container
(
  ct_id numeric,
  container_object bytea
)
1
  • String sql="select container_objects from contanier where ct_id=232"; ResultSet rs=stmt.executeQuery(sql); while(rs.next()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(baos); Vector scontObject=new Vector(); scontObject.add("container_objects"); oout.writeObject(scontObject); System.out.println(oout.toString()); //System.out.println(baos.toString()); oout.close(); } i tried like this i got following result java.io.ObjectOutputStream@efd552 Commented Sep 22, 2010 at 9:45

1 Answer 1

4

Take a look at encode() to transform a bytea to a string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.