简体   繁体   中英

Write Long Raw bmp file to Oracle Databse using Java

I'm trying to save a bmp file to a long raw column in a legacy oracle database using java, but i does not work well. This is the code i used:

InputStream input2 = new ByteArrayInputStream(bytesArchivo);
String sql = "UPDATE firma_legal SET " +
                     "      firma = ? " +
                     "WHERE cod_unicom = 1120";
OraclePreparedStatement  stat =
                (OraclePreparedStatement) connection.prepareStatement(sql);
stat.setBinaryStream(1, input2, (int)archivo.length());
stat.executeUpdate();
input2.close();

The code execute well, but when i see in the database, it does not update the row that i want, instead, it put this string "BMF;".

行已更新

How can i do to insert this file into long raw column?

Thanks for your help.

Please check the values archivo.length() , is that equals 4?

or

There or only 4 bytes available in input2 , try input2.available() to check out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM