I'm transferring data from one hsqldb to another. Both have the same tables etc. The schemas are absolutely identical.
I have some massive binary columns (not my design decision, but I got to work with it). Those I read as a string with the rawtohex
function from database A
and write to database B
using the hextoraw
function.
The code looks something like that:
String query = "SELECT rawtohex(PAYLOAD) FROM TABLE_X;"
Statement selectPst = connA.createStatement();
ResultSet data = selectPst.executeQuery(query);
String insert = "INSERT INTO TABLE_X (PAYLOAD) VALUES (hextoraw(?))";
PreparedStatement insStmt = connB.prepareStatement(insert);
data.next();
insStmt.setString(1, data.getString(1));
insStmt.executeUpdate(); // <- java.sql.SQLDataException: data exception: string data, right truncation
Usually, this Exception is thrown if the column is too small for the data. But the data is in a database with the same table and columns and if I do the same thing manually using the hsqldb tool, it works.
I'm grateful for any idea what could possibly cause this!