cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading File from WebDynpro and store to BLOB field

Former Member
0 Kudos

REPOSTING; Need help

Hello all,

I have already gone through the tutorials available here as for uploading files. My application uploads text files and parses (buffer reads) it and insert into a varchar2 field. But the requirement changed: Now, the files allowed for upload is of any file type.

Now the problem with the tutorial I have is that it stores the files on the project's folder - and I see it as not applicable to my application. Hence, I decided to store it onto a BLOB field on an Oracle databse.

I looked into Bean Managed Persistence - but I can't figure a way to have it inserted into the database.

I'm using WebDynpro. How do I do this, please?

Thank you.

Regards,

Jan

-


I have already been able to bind the file to value attribute of FileSource -- what should I do next to have this inserted to the BLOB field?

Thank you in advance.

-Jan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Jan,

Please go through the below thread to get connection to oracle database.

Regards

Narendra

Former Member
0 Kudos

Hi,

See If the Below Code can help you.

Inserting a BLOB

// CREATE TABLE t1 (c1 INT PRIMARY KEY NOT NULL, c2 BLOB(5M)); 

PreparedStatement pstmt = conn.prepareStatement ("INSERT INTO t1 VALUES (?,?)");
pstmt.setInt (1, 100);
File fBlob = new File ( "here you can pass your file );
FileInputStream is = new FileInputStream ( fBlob );
pstmt.setBinaryStream (2, is, (int) fBlob.length() );
pstmt.execute ();

...

please revert if you require more info

Regards

Narendra

Former Member
0 Kudos

Hello Narendra,

Thank you for your prompt response!

I'm guessing, that I could also create the connection object on the webdynpro project?

How does that go? Perhaps a snippet of code, if it's okay?

Thank you.

Regards,

Jan