Haythem
Haythem

Reputation: 417

insert BLOB file from Local to DB

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

Upvotes: 2

Views: 2292

Answers (2)

Shekhar
Shekhar

Reputation: 11788

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

Upvotes: 1

Buhake Sindi
Buhake Sindi

Reputation: 89199

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.

Upvotes: 2

Related Questions