insert BLOB file from Local to DB

£可爱£侵袭症+ 提交于 2019-12-11 01:07:52

问题


I am trying to allow users to choose a file from local hard disk and to insert it with java in a Oracle Data base as BLOB value.

The setBinaryStream did not allow big files.

with the setBlob I have no way to convert the file to a blob.

Is the import of a blob file from the DB then overwrite it the unique solution?.

Regards, Haythem


回答1:


This is a suggestion that I've used before

In essence a file is an array of bytes, what you can do is to read the file data and use PreparedStatement.setBytes(index, byte[]) to store the data.

Hope this helps.




回答2:


You need to read the file as any byte array. This byte array can be assigned to Oracle BLOB column.



来源:https://stackoverflow.com/questions/4283777/insert-blob-file-from-local-to-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!