File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Rpt : Image Inesertion some1 check this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Rpt : Image Inesertion some1 check this code" Watch "Rpt : Image Inesertion some1 check this code" New topic
Author

Rpt : Image Inesertion some1 check this code

akilan kandaswamy
Greenhorn

Joined: Feb 26, 2001
Posts: 4
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(); }
}
}
David Freels
Ranch Hand

Joined: Feb 01, 2001
Posts: 102
Use PreparedStatement instead of Statement when retrieving data from BLOBs or CLOBs.
David
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rpt : Image Inesertion some1 check this code
 
Similar Threads
Retreving PDF File from Database using Java
Could Anyone correct my Error with JDBC
Problem with servlet reading images in database!
displaying image from database
How to give Servlet response from Tag Handler class?