File file = new File("image/temp.jpg");
FileInputStream fis = new FileInputStream(file);
System.out.println("aaa");
String insertInfo = "use student insert into stuInfo(id,name,sex,resume,photo) values(?,?,?,?,?)";
PreparedStatement ps = conn.prepareStatement(insertInfo);
ps.setInt(1, employee.getId());
ps.setString(2, employee.getName());
ps.setString(3, employee.getSex());
ps.setString(4, employee.getResume());
System.out.println(file.length()+":"+fis.available());
ps.setBinaryStream(5, fis,(int)file.length());
ps.execute();关键代码如上,问题是开始这样是插入成功的,不知道为什么突然就会出现com.microsoft.sqlserver.jdbc.SQLServerException: 将截断字符串或二进制数据错误,然后fis.available()和file.length()的值是一样的,应该不会截断的吧,求解