Following is the code I have used:
byte[] bkey = key.getEncoded();
String query = \"INSERT INTO keytable (name, key) VALUES (?,?)\";
PreparedStatement pstmt
Try using "setBinaryStream()" instead of "setBytes()", and pass it a ByteArrayInputStream constructed on your byte array. This, of course, assumes that the data type assigned to the column can store bytes... Make sure it is a BLOB, BINARY, or VARBINARY.
Also, use backticks to enclose your objects. "key" is a SQL keyword, and other than that it is just a good habit:
String query = "INSERT INTO `keytable` (`name`, `key`) VALUES (?,?)";