-1

我为文件创建了一个表,我为文件 varbinary(MAX) 放置了数据类型,当我尝试上传文件时,它显示给我:

String or binary data would be truncated

当我像这样编写插入查询时:

   String sql = "INSERT INTO contacts (first_name, last_name, photo) values (?, ?, ?)";
   PreparedStatement statement = conn.prepareStatement(sql);
   statement.setString(1, firstName);
   statement.setString(2, lastName);

   if (inputStream != null) {
       // fetches input stream of the upload file for the blob column
       statement.setBlob(3, inputStream);
   }

我也尝试了 setBinaryStream 但它仍然给了我同样的错误所以请帮助我如何解决它?

4

1 回答 1

0

该错误意味着在将数据保存在VARBINARY(MAX)列中时,您的二进制数据将被截断。只需将列的类型更改为BLOB.

于 2013-04-13T16:18:46.523 回答