Wednesday, September 4, 2013

OracleDB: How to save a byte array to a BLOB field in Java


PreparedStatement statement= getConnection().prepareStatement("INSERT INTO MYTABLE(MYBLODFIELD) VALUES(?)");


byte binData[] = myString.getBytes();
inStream = new ByteArrayInputStream(binData)
statement.setBinaryStream(1, inStream, binData.length);
statement.executeUpdate();



No comments: