I am using hsqldb version 2.2.5 in my application sometimes I am getting
org.hsqldb.HsqlException: data exception: string data, right truncation.
So I want to know what are the possible reasons for that. I am not inserting any data like longvarchar in a varchar column.
http://sourceforge.net/tracker/index.php?func=detail&aid=2993445&group_id=23316&atid=378131
I searched above link but could not get proper feedback.
Given below the exception stack This exception is not happening frequently.
So what could be the reason for that and how to set the data type length in script file to increase at run time ?
java.sql.SQLException: data exception: string data, right truncation
at org.hsqldb.jdbc.Util.sqlException(Util.java:255)
at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(JDBCPreparedStatement.java:4659)
at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(JDBCPreparedStatement.java:311)
at com.dikshatech.agent.db.NodesRuntimeTable.persistData(NodesRuntimeTable.java:151)
at com.dikshatech.agent.jobs.WorkFlowJob.execute(WorkFlowJob.java:108)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.hsqldb.HsqlException: data exception: string data, right truncation
at org.hsqldb.error.Error.error(Error.java:134)
at org.hsqldb.error.Error.error(Error.java:104)
at org.hsqldb.types.CharacterType.castOrConvertToType(CharacterType.java:523)
at org.hsqldb.types.CharacterType.convertToType(CharacterType.java:638)
at org.hsqldb.StatementDML.getInsertData(StatementDML.java:921)
at org.hsqldb.StatementInsert.getResult(StatementInsert.java:124)
at org.hsqldb.StatementDMQL.execute(StatementDMQL.java:190)
at org.hsqldb.Session.executeCompiledStatement(Session.java:1344)
at org.hsqldb.Session.execute(Session.java:997)
at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(JDBCPreparedStatement.java:4651)
The maximum size of a VARCHAR column is user-defined. If the inserted data is larger than this, an exception is thrown. The example below defines a table with a VARCHAR(100) column, which limits the size to 100 characters.
CREATE TABLE T (ID INT, DATA VARCHAR(100))
You can use a database manager and execute the SCRIPT command to see all your table definitions and their column size. Alternatively, SELECT * FROM INFORMATION_SCHEMA.COLUMNS
shows the characteristics of each column.
You can use the ALTER TABLE table_name ALTER COLUMN col_name SET DATA TYPE
to increase the size of an existing column.
For Hibernate/HSQLDB automatically generated schema via @Column
annotation on @Entity
field of type String you might need to provide length
atrribute. Otherwise the length will default to 255 and long input will not fit:
@Lob
@Column(name="column_name", length = 1000)
private String description;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With