Here you can find the source of writeStringToBlob(String value, PreparedStatement preparedStatement, int index)
public static void writeStringToBlob(String value, PreparedStatement preparedStatement, int index)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.sql.PreparedStatement; import java.sql.SQLException; public class Main { public static void writeStringToBlob(String value, PreparedStatement preparedStatement, int index) { try {/*from ww w .jav a 2s.c om*/ final byte[] bytes = value.getBytes(StandardCharsets.UTF_8); preparedStatement.setBinaryStream(index, new ByteArrayInputStream(bytes), bytes.length); } catch (SQLException e) { throw new RuntimeException(e); } } }