Inserting a byte-array into a db

Hi,

I want to store a byte-array in a db. The problem is that the method to insert values into a database need a string.

So if i make something like execute("insert into table test values('" + byteArray +"')");

the stored values is not equal with the original byte-array.

Any ideas?

Message was edited by:

Olek

[408 byte] By [Oleka] at [2007-11-27 9:42:18]
# 1

>

> Any idea

Your code assumes that the toString() method on an array produces a String that reflects the content of the array. It does not - it just represents a pseudo reference to the array and has nothing at all to do with the content.

Use prepared statements and BLOB.

sabre150a at 2007-7-12 23:45:26 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Thank you for your hint,I use the toString() method with Date-objects too.There it works...i try to implement your solution.
Oleka at 2007-7-12 23:45:26 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
> Thank you for your hint,> > I use the toString() method with Date-objects too.> There it works...But it is probably wrong to do this! Again use PrepartedStatement but this time using the setDate() method.
sabre150a at 2007-7-12 23:45:26 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...