This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Oracle/OAS and the fly likes write a bytearray to an oracle db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "write a bytearray to an oracle db " Watch "write a bytearray to an oracle db " New topic
Author

write a bytearray to an oracle db

snoofle
Greenhorn

Joined: Jan 09, 2002
Posts: 26
hello all,
i have a big problem with writing a bytearray to an oracle db and display it via a servlet
i have a function to generate a pdf with the pdflib

then i want to store the bytebuffer = pdf.get_buffer(); into an oracle database with this script:

when i then try to display the result with this servlet then i get no pdf file displayed

has anybody an idea where my error is ?
tia
andreas spiessl
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Hi
You can read this post: http://www.coderanch.com/t/297456/JDBC/java/Retreiving-image-JDBC
/Rene


Regards, Rene Larsen
Dropbox Invite
snoofle
Greenhorn

Joined: Jan 09, 2002
Posts: 26
hello rene, hello all
i have tried it with the code and no pdf file is displayed.
i have test my loading servlet with the database an i function, so now i think the error must be in

has anybody an idea
tia
andreas spiessl
[ June 19, 2002: Message edited by: andreas spiessl ]
Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
Could you insert the pdf files in the database successfully?
Try to get the size of the blob and match it with the actual file and make sure that it is loaded properly.
What version of adobe acrobat are you using? I had several problems displaying the pdf files on the browser, especially with some versions of IE. Have you tried to refresh the browser? I am using bfiles instead of blob to store the pdf files. If you like I can give my code to display the pdf files in the browser.
Regards
Beksy
[ June 19, 2002: Message edited by: Beksy Kurian ]
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Hi
This is the way I saves a byte[] in a Blob:

I do not use the Oracle Blob (getBLOB() is from Oracle and getBlob() is standard) and OracleResultSet, but the one from the standard JDBC API
/Rene
[ June 19, 2002: Message edited by: Rene Larsen ]
snoofle
Greenhorn

Joined: Jan 09, 2002
Posts: 26
hello beksy,
i am using ie 4/5 and acrobat 5.
the insert doesn't work correctly,
(maybe the pdflib get_buffer function has an error)
i don't know where my error is ...
i would be nice if i can have a look at your code for insert and displying pdf files
tia
andreas spiessl
[ June 19, 2002: Message edited by: andreas spiessl ]
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Hi
You have to change the way you generate your pdf-doc.
I have tested your implementation and it is not working, but this code is:

Saving and loading the pdf-doc is the way shown earlier.
Hope this helps
/Rene
[ June 20, 2002: Message edited by: Rene Larsen ]
snoofle
Greenhorn

Joined: Jan 09, 2002
Posts: 26
hello rene,
you've been right
pdf.close() and after that pdf.get_buffer() was the error
thanks a lot
andreas spiessl
 
Consider Paul's rocket mass heater.
 
subject: write a bytearray to an oracle db
 
Similar Threads
write a bytearray to an oracle db
Problem when readin blob
inserting BLOB values using prepared statement
Reading From a Binary Large Object(BLOB)
Connection pooling issue in Apache 6.0