相关文章推荐
骑白马的葡萄  ·  SQL ...·  10 月前    · 
兴奋的蘑菇  ·  python - ...·  1 年前    · 
成熟的圣诞树  ·  Google ...·  1 年前    · 
玩足球的铅笔  ·  C#winform ...·  2 年前    · 
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class ByteArrayToBlob { public static void main (String[] args) { byte [] byteArray = new byte []{ 1 , 2 , 3 , 4 , 5 }; try ( Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement( "insert into table_name (column_name) values (?)" )) { Blob blob = conn.createBlob(); blob.setBytes( 1 , byteArray); stmt.setBlob( 1 , blob); stmt.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); private static Connection getConnection () throws SQLException { // 这里可以使用你喜欢的数据库连接方式 return null ;
  •