|
Strange,
It
might work, but an image is binary data, and a String is character based.
Doesn't seem logical to me to use the getString here.
anyway, here's the relevant part of my
code:
public
void getResource(OutputStream os) throws IOException{
Connection conn = getConnection(); PreparedStatement stmt = null; try{ stmt = conn.prepareStatement("select data from resource where article_id = ? and name = ? "); stmt.clearParameters(); stmt.setInt(1,articleId); stmt.setString(2,resourceName); ResultSet rs = stmt.executeQuery(); if (rs.next()){ InputStream in = rs.getBinaryStream(1); byte[] buffer = new byte[4096]; int len = 0; while ((len=in.read(buffer)) != -1){ os.write(buffer,0,len); } } rs.close(); } catch (SQLException e){ System.out.println(e.getMessage()); while ((e=e.getNextException()) != null){ System.out.println(" next "+e.getMessage()); } } finally { try{ if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (SQLException e){ System.out.println(e.getMessage()); } } } Geert
Van Damme
|
- oracle news group EJB ForAll
- Re: oracle news group [Moisey Oysgelt]
- BLOBs within MySQL and JSP Pau Garc�a
- Re: BLOBs within MySQL and JSP Papo Napolitano
- Re: BLOBs within MySQL and JSP Pau Garc�a
- Re: BLOBs within MySQL and JSP Papo Napolitano
- Geert Van Damme
