dcsimg
How to retrieve the image using JDBC? i am using MSAccess(insert the mage using OLEobject)
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   gopi_natarajan
Posted On:   Thursday, July 29, 2004 11:00 PM

Here i am giving the code as i wrote: I am getting the output like only image layout..No image display..So please give teh solution to me.. import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.lang.String; public class databass extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); res.setContentType("image/gif"); Connection con=null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odb   More>>

Here i am giving the code as i wrote:
I am getting the output like only image layout..No image display..So please give teh solution to me..

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.lang.String;
public class databass extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
res.setContentType("image/gif");
Connection con=null;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:jps");
Statement stmt=con.createStatement();
ServletOutputStream ot=res.getOutputStream();
ResultSet rs = stmt.executeQuery("SELECT IMAGE FROM PICTURES");

if (rs.next( ))
{
BufferedInputStream gifData = new BufferedInputStream(rs.getBinaryStream("IMAGE"));
byte[] buf = new byte[4 * 1024]; // 4K buffer
int len;
while ((len = gifData.read(buf, 0, buf.length)) != -1)
ot.write(buf,0,len);
}
//PrintWriter out = res.getWriter(); out.println("getErrorcode" );//reports
}
catch(Exception e) { } //PrintWriter out = res.getWriter(); out.println("error");

try{ if (con!=null) con.close(); }
catch(SQLException e) {}

}
}


Thanks in advance,
Gopi.N.

   <<Less
About | Sitemap | Contact