I created a table for file I put the datatype for file varbinary(MAX) and when I am trying to upload the file it show me:
String or binary data would be truncated
When I wrote insert query like this:
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);
}
I tried setBinaryStream too but it still gave me same error so please help me how to solve it?