Answer to this is as follows:
1. ensure that the 10g version of ojdbc14.jar is deployed to server/default/lib
(if using default)
2. write method to obtain BLOB from table and write it to an OutputStream (in
this example has been placed in a class called ProductBO - see 3 below)
public void writeImageForProduct(String id, OutputStream os) throws
DAOException {
Connection conn = null;
ResultSet rs = null;
int v = 0;
conn = connectionHelper.getConnection();
PreparedStatement stmt = null;
try
{
stmt = conn.prepareStatement("SELECT dvd_title_id, cover_image
FROM dvdtitle where dvd_title_id = '" + id + "'");
rs = stmt.executeQuery();
while (rs.next())
{
Blob blob = rs.getBlob(2);
try {
InputStream imageStream = blob.getBinaryStream();
while ((v = imageStream.read()) != -1) {
os.write(v);
}
imageStream.close();
}
catch (IOException e) {
throw new DAOException(e);
}
}
rs.close();
}
catch (SQLException e) {
throw new DAOException("SQL Exception " + e.getMessage(), e);
}
finally {
connectionHelper.closeConnection(conn, null);
}
}
3. Extract from servlet:
.................
response.setContentType("image/gif");
ProductBO productBO = new ProductBO();
try {
ServletOutputStream outputStream = response.getOutputStream();
productBO.writeImageForProduct(dvd_image_id,outputStream);
response.flushBuffer();
} catch (ProductException e) {
throw new ServletException(e.getMessage());
}
..................
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884518#3884518
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884518
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user