При попытке выполнить подготовленное состояние с параметрами в этом коде
public void Insert(String TreeType, String LastWatered, String PlantDate) {
try {
String G = "INSERT INTO Trees (TreeType, LastWatered, PlantDate) VALUES
(?, ?, ?)";
PreparedStatement preparedStatement = conn.prepareStatement(G);
preparedStatement.setString(1, TreeType);
preparedStatement.setString(2, LastWatered);
preparedStatement.setString(3, PlantDate);
preparedStatement.executeUpdate();
} catch (SQLException ex) {
Logger.getLogger(TreeArr.class.getName()).log(Level.SEVERE, null, ex);
}
}
Я получаю эту ошибку
Sep 09, 2018 2:15:51 AM pat.ConnectDb Insert
SEVERE: null
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 data exception:
string data, right truncation; table: TREES column: TREETYPE
at
net.ucanaccess.jdbc.UcanaccessPreparedStatement.executeUpdate(UcanaccessPreparedStatement.java:269)
at pat.ConnectDb.Insert(ConnectDb.java:41)
at pat.AddTreeGUI.GoButton1ActionPerformed(AddTreeGUI.java:218)
at pat.AddTreeGUI.access$100(AddTreeGUI.java:13)
at pat.AddTreeGUI$2.actionPerformed(AddTreeGUI.java:67)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
...
Caused by: org.hsqldb.HsqlException: data exception: string data, right truncation; table: TREES column: TREETYPE
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.Table.enforceTypeLimits(Unknown Source)
at org.hsqldb.Table.insertSingleRow(Unknown Source)
at org.hsqldb.StatementDML.insertSingleRow(Unknown Source)
at org.hsqldb.StatementInsert.getResult(Unknown Source)
at org.hsqldb.StatementDMQL.execute(Unknown Source)
at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 46 more
Caused by: org.hsqldb.HsqlException: data exception: string data, right truncation
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.types.CharacterType.convertToTypeLimits(Unknown Source)
... 53 more
однако, это работает, когда я ввожу реальную строку, например
preparedStatement.setString(1, "Hello World");
Как это можно сделать?