• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Rpt : Image Inesertion some1 check this code

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai ,
I tried to retrieve an image from MSACCESS using the following code im getting an Exception IOException:MEthod not implemented some1 pls help me, how to enter an imae into an DataBase?

import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetImage4 extends HttpServlet
{
Connection con;
Statement st;
ResultSet rs;
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
try{
res.setContentType("image/gif");
PrintWriter out=res.getWriter();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:sasi");
st=con.createStatement();
rs=st.executeQuery("SELECT * FROM IMAGE");

rs.next();

BufferedInputStream bis=new BufferedInputStream(rs.getBinaryStream(2));
byte[] bb=new byte[4 * 1024];
int dd=rs.getInt(1);

int len=0;
while(len!=-1)
{ len=bis.read(bb,0,bb.length);
out.print(len);
}
}
catch(Exception e)
{ System.out.println(e);e.printStackTrace(); }
}
}
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use PreparedStatement instead of Statement when retrieving data from BLOBs or CLOBs.
David
 
reply
    Bookmark Topic Watch Topic
  • New Topic