Inserting byte into MySQL
I've been working at this for hours and read all sorts of stuff of the web and I just can't seem to figure out how to do this.
I have 2 blob fields in my MySQL table that I'm trying to insert the byte arrays into. When I try to insert it I get an SQL syntax Exception:
This is how I try to insert it:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[B@35d9dc39, [B@72093dcd)' at line 1
Obviously there are some try statements etc. hanging around that I have removed for easy reading and this is just a simple version of what I plan to do as later I'm going to query the DB for the blobs and compare them to inputs but I don't get what I'm doing wrong here with this insert. It looks as though MySQL is having a problem with the contents of the blob. Would a prepared statement make a difference or am I just not handling this byte array properly?
String sel = "INSERT INTO config.user (name, password) VALUES (" + usrDigest + ", " + pswdDigest + ")";
Statement stmt = conn.createStatement();
Just as a bit of background: the byte arrays are the result of SHA-1 digests. I'm trying to make a simple user authorisation system with one-way hashing.