title: How to insert byte arrays into SQL via Java?
body: <p>So I know this question has been asked a few different places, but I wasn't able to get a solid answer. So, I'm trying to store usernames, ids, salts, and hashes, and so I've just created the account, and I need to insert the data into the database. I thought just do it like this: <code>int newResults = statement.executeUpdate("INSERT INTO data VALUES (1, 'CyanCoding', " + hash + ", " + salt + ")");</code></p>
  
  <blockquote>
    <p>Just so you know, everything is good except in the db except hash and salt, and those variables are BINARY(16) in the db and just byte array in the java program.</p>
  </blockquote>
  
  <p>So, I ran it and I got "You have an error in your SQL syntax" (very helpful). So I looked it up and people in other answers suggested doing it like this: <code>int newResults = statement.executeUpdate("INSERT INTO data VALUES (1, 'CyanCoding', @hash, @salt)");</code></p>
  
  <p>And that ran fine, but when I checked the values in the database, hash and salt were both <code>null</code>. So, ignoring the fact that I probably used <code>@hash</code> incorrectly, how should I insert my byte arrays into my SQL table?</p>