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
;