Results 1 to 2 of 2
Thread: Read file from database
- 06-09-2010, 05:20 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
Read file from database
Hello,
I´m new to java and new to this forum, so I hope you will be patience with me :)
What I´m trying to do is this:
I read a file from database, and I need to show this file directly to the user. This file is saved as Blob in Oracle database and I read it in this way:
String sql = "SELECT image FROM pictures ";
PreparedStatement stmt = conn.prepareStatement(sql);
ResultSet resultSet = stmt.executeQuery();
File image = new File("D:\\java.gif");
FileOutputStream fos = new FileOutputStream(image);
byte[] buffer = new byte[1];
//
// Get the binary stream of our BLOB data
//
InputStream is = resultSet.getBinaryStream(1);
while (is.read(buffer) > 0) {
fos.write(buffer);
}
fos.close();
Now I need to "show" this file to the user but I have no clue how.
If you can suggest me...any idea will be welcome.
Thank you in adavnce.
- 06-09-2010, 05:53 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Similar Threads
-
how to read openproj(Projity) file i.e. ,POD file(Project Management file)
By mahendra.athneria in forum New To JavaReplies: 0Last Post: 02-11-2009, 09:53 AM -
How can I call my database read method to display its ArrayList?
By matpj in forum New To JavaReplies: 3Last Post: 01-29-2009, 10:20 AM -
how to insert date field read from Excel using JExcel to database
By saran123 in forum JDBCReplies: 1Last Post: 10-10-2008, 08:47 AM -
how to read a url parameter to query a database
By kwesiaryee in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-01-2008, 02:38 PM -
How to read block of rows from database tables
By lmenaria in forum JDBCReplies: 1Last Post: 08-08-2007, 01:22 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks