This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Saving Doc as BLOB in SQL DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Saving Doc as BLOB in SQL DB" Watch "Saving Doc as BLOB in SQL DB" New topic

Saving Doc as BLOB in SQL DB

Michael Paul

Joined: Mar 29, 2008
Posts: 14
Hi Ranchers,

I made a JFileChooser, so that you can select only textual documents, and then I want to be able to save this to a database but I really have no idea of where to start with BLOBs can someone give me a little starting push with this topic...I read examples online about how to retrieve BLOBS which seemed very easy...I am jsut not sure how to save a document as a BLOB to begin with..this is the code for my filechooser incase you wanted to see it:

Just so you know, I do know how to write to the DB, I just don't know how to handle BLOBs. Any help at all would be appreciated, =)

[ April 23, 2008: Message edited by: Michael Paul ]
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30076

The key is to create a binary input stream rather than a blob and call stmt.setBinaryStream().

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
jQuery in Action, 2nd edition
subject: Saving Doc as BLOB in SQL DB
Similar Threads
JFileChooser problems
excluding files using FileFilter
How will i get all the shared folder names in windows7 from entire network
How to open a file using Java
FileChooser.getSelected() turn into Blob