I used vertx 3.9.12 and JDBCCLient. How to insert image to BLOB column? Thank in advance
Advertisement
Answer
Unwrap the io.vertx.ext.sql.SQLConnection to java.sql.Connection and then create a Blob that you add to the params:
Connection jdbcConn = sqlConnection.unwrap();
Blob blob = jdbcConn.createBlob();
blob.setBinaryStream(1).write(bytes);
JsonArray params = new JsonArray().add(blob);
connection.queryWithParams("INSERT INTO XXX (b) VALUES (?)", params, handler);