hibernate存数据的时候报错
信息: schema update completeHibernate: insert into FileEntity (mybyte, name) values (?, ?)
2013-11-13 23:27:10 org.hibernate.util.JDBCExceptionReporter logExceptions
警告: SQL Error: 8152, SQLState: 22001
2013-11-13 23:27:10 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: 将截断字符串或二进制数据。
我想将文件用二进制的形式存在数据库中,
实体类中字段写的是:byte[] mybyte;
求给位帮帮忙~ hibernate ,java sql SQL Error: 8152 --------------------编程问答-------------------- protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
FileUpDownTool upDownTool = new FileUpDownTool();
List<Object> list;
try {
list = upDownTool.sortData(request);
Map<String, String> hms = (Map<String, String>) list.get(0);
Map<String, InputStream> hmb = (Map<String, InputStream>) list.get(1);
DAOFile daofile = new DAOFile();
FileEntity myfile = new FileEntity(); // 实体类
String name = hms.get("username");
myfile.setName(name);
String fileName = hms.get("picFile");
if (hmb.containsKey(fileName)) {
InputStream is = hmb.get(fileName);
byte[] bytePic = new byte[is.available()];
@SuppressWarnings("unused")
int i = is.read(bytePic);
myfile.setMybyte(bytePic);
}
daofile.addBusiness(myfile);
} catch (FileUploadException e) {
e.printStackTrace();
}
} --------------------编程问答-------------------- 数据库相关字段用的是 BLOB 吗?
补充:Java , Web 开发