SQLException: String or binary data would be truncated

J

jrefactors

The Java program inserted data to table, but it throws exception
"String or binary data would be truncated."

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Str
ing or binary data would be truncated.
at
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source
)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown
Source)
at
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown
Source)
at
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown
Source)
at
com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(
Unknown Source)
at
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Sour
ce)
at
com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType
(Unknown Source)
at
com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown
Source)
at
com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)

at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown
Source)
at
com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown S
ource)
at com.microsoft.jdbc.base.BaseStatement.executeUpdate(Unknown
Source)
at SQLHelper.insertRecord(SQLHelper.java:24)

Any ideas? thanks!!
 
Q

quaidian

Hi,

This exception is thrown when one of database table column cannot keep
the amount of data being inserted into it. For example your database
table has a colum named "TestColumn" of type "VARCHAR(10)". Now if you
will try to insert a string of length greater than 10, the program will
throw same exception...

Regards,

Yasir Khan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top