数据库字段是bolb类型的 现在插入数据的时候总不能插入成功
后台是可以得到图片的 验证过 就是插入时候出问题 public String addArticle(){
System.out.println("-----=---------------==========");
System.out.println(fileContentType + "****" + fileFileName);
Article article=new Article();
article.setWDate(new Date());
// article.setArtText(Hibernate.createBlob(getStringParameter("aText").getBytes()));
try {
FileInputStream input=new FileInputStream(file);
// String path=ServletActionContext.getRequest().getRealPath("/") + "temp";
// File f=new File(path);
// if(!f.exists()){
// System.out.println("file");
// f.mkdirs();
// }
// FileOutputStream out=new FileOutputStream(new File(path +"\\" + fileFileName));
// byte[] b=new byte[1024]; 
// int len=0;
// while((len=input.read(b))>0){
// out.write(b, 0, len);
// }
Blob b=Hibernate.createBlob(input);
article.setPhoto(b);
input.close();
// out.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
getEntityDao().save(article); return "showArt";
}FileInputStream input=new FileInputStream(file);
Blob b=Hibernate.createBlob(input);
article.setPhoto(b);
这三句是插入的  可以获取图片我用注释的那部分
后台报这异常
image/pjpeg****3406.jpg
Hibernate: insert into Article (Photo, WDate) values (?, ?)
2010-04-30 10:48:24,265 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 0, SQLState: S1000>
2010-04-30 10:48:24,265 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Error reading from InputStream java.io.IOException>
2010-04-30 10:48:24,343 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]>
2010-04-30 10:48:24,515 INFO [org.springframework.jdbc.support.SQLErrorCodesFactory] - <SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]>

解决方案 »

  1.   

    上面是因为 流关闭了  下面这才是主要错误 Hibernate: insert into Article (Photo, WDate) values (?, ?)
    2010-04-30 11:04:35,468 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 1064, SQLState: 42000>
    2010-04-30 11:04:35,468 ERROR [org.hibernate.util.JDBCExceptionReporter] - <You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't”??>????L? ?·`??????-<:g¨?°?????????lw|ciJ??\01H?au?\0$?J?*?&\05?eO?8—u<' at line 1>
    怎么出现乱码
      

  2.   

    blob最大支持64K,是不是图片太大?
    mysql的blob一共4种类型,大小不一样。