我为文件创建了一个表,我为文件 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 但它仍然给了我同样的错误所以请帮助我如何解决它?