我尝试将文件作为longblob存储到mysql数据库时,字符串值不正确

时间:2014-10-15 09:18:03

标签: java mysql spring hibernate

我有一个简单的Web应用程序来上传文件并将它们存储在longblob中的mysql数据库中。但我得到以下例外:

Caused by: java.sql.SQLException: Incorrect string value: '\xA2\x04\x02(\xA0\x00...' for column 'value' at row 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1504)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133)
    ... 68 more

这是我的表格:

<form id="myForm" action="/creategroup" enctype="multipart/form-data" method="POST">
    <input type="file" name="component_1" id="component_1">
    and other stuff...

这是该领域的Hibernate定义:

@Audited
@Column(name = "value")
@Lob
private byte[] value;

这是我对该字段的mysql定义:

value LONGBLOB NOT NULL

可能是什么问题?我该怎么检查?我应该改变什么来使它工作?

0 个答案:

没有答案