Exception on excuteUpdate
I am getting an exception as
com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
The exception is thrown at the following line:
PrepareStmt.setBinaryStream(1, new ByteArray开发者_如何学编程InputStream(data), data.length);
updatePrepareStmt.executeUpdate();
I am using MS-SQL db. Can anyone help me solve this problem?
The datatype of the column in which I am trying to insert data is varbinary and the length of the data is also not large. I am just inserting "test".
UPDATE
Now I have increased the size of datatype varbinary. Made it to 1024, but I get new Exception now :-com.microsoft.sqlserver.jdbc.SQLServerException:The conversion from varbinary to BLOB is unsupported
Can anyone comment on this Exception?
As the exception message sais, your data seems to be larger than the database field it should be written to. What is the maximum of data.length
and what's the maximum length of your column?
Increase the column capacity.. if it is varchar(20)
make it varchar(200)
or something that can accomodate your data.
精彩评论