Reputation: 4410
With this query
INSERT INTO `schema`.`table` (`col1`, `col2`)
VALUES ('value1', unhex(sha2("value2", 256)));
how to prepare a statement for the jdbc driver with one value produced by those functions?
preparedStatement = connect.prepareStatement("insert into schema.table values (?, ?)");
Upvotes: 0
Views: 2340
Reputation: 724
Use the following format to get the job done.
preparedStatement = connect.prepareStatement("insert into schema.table values (?, unhex(sha2(?,256)))");
preparedStatement.setString(1, "value1");
preparedStatement.setString(2, "value2");
Upvotes: 4
Reputation: 3793
Try this
preparedStatement = connect.prepareStatement("insert into schema.table values (?, unhex(sha2(?, 256)))");
Upvotes: 1