
I am trying to upload a image to ms-acess using jsp,and my problem is that it shows some error int the browser that "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect ".I think i set wrong datatype for table column in which my image going to be saved.I set the data type as OLE Object. Is there any suggestion?
my code was..
<%@page import="java.sql.*,java.io.*"%>
<%
try{
InputStream sImage;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");
File imgfile = new File("C:/rose.jpg");
FileInputStream fin = new FileInputStream(imgfile);
PreparedStatement pre = con.prepareStatement("insert into user(name,address,image) values(?,?,?)");
pre.setString(1,"A");
pre.setString(2,"Delhi");
pre.setBinaryStream(3,fin,(int)imgfile.length());
pre.executeUpdate();
out.println("Inserting Successfully!");
pre.close();
con.close();
}
catch(Exception ex){
out.println("error :"+ex);
}
%>
please help!
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.