1

How can I store the following data structure:

byte[] number = new byte[1000];

in bytea column in PostgreSQL with

INSERT INTO blobT command?

 CREATE TABLE blobT (
    blob      bytea
 );

What is the equivalence of bytea in MySQL and Microsoft SQL?

1
  • you can use blob in mysql. Commented Jul 4, 2013 at 11:18

1 Answer 1

1

For MySql you can do

 CREATE TABLE blobT (
    bytea blob;     
 );


String query = "INSERT INTO blobT (bytea) VALUES (?)"; 
PreparedStatement pstmt = conn.prepareStatement(query);
pstmt.setBytes(1, bytea);
pstmt.execute();
Sign up to request clarification or add additional context in comments.

2 Comments

How would you store bytea in Java?
luksmir, I think bytea is escaped by the jdbc driver, so you should just be able to do a standard parameterized query, with the appropriate variable binding.

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.