我正在尝试构建一个仅用于保存记录的应用程序,现在将其删除,我是Java和数据库的新手,当我保存它时可以正常工作,但是当我尝试删除它时出现错误:
Comparisons between 'LONG VARCHAR (UCS_BASIC)' and
'LONG VARCHAR (UCS_BASIC)' are not supported.
private void SaveBtnActionPerformed(java.awt.event.ActionEvent evt) {
try{
conn = DriverManager.getConnection("jdbc:derby://localhost:1527/Test", "app", "testcode");
st = (Statement) conn.createStatement();
String sql = "INSERT INTO APP.UNTI(ID,NAME) VALUES(?,?)";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, J1.getText().trim());
ps.setString(2, J2.getText().trim());
if(ps.executeUpdate()>0){
JOptionPane.showMessageDialog(null, "insert succusful");
}
}catch(SQLException xmp){
System.out.println("error");
}
}
private void RemoveBtnActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
conn = DriverManager.getConnection("jdbc:derby://localhost:1527/Test", "app", "testcode");
st = (Statement) conn.createStatement();
PreparedStatement ps = conn.prepareStatement("DELETE FROM UNTI WHERE NAME = ? ");
System.out.println("ok");
ps.setString(1,J2.getText().trim());
if(ps.executeUpdate() > 0){
JOptionPane.showMessageDialog(null, "insert succusful");
}
}catch(SQLException xmp){
System.out.println(xmp.getMessage() );
}catch(NullPointerException xmp){
System.out.println(xmp.getMessage() );
}
}
答案 0 :(得分:1)
您无法比较长varchar,就像无法索引它们一样。
Comparison table documentation
图片取自文档(提供链接),请注意,不能将long varchar与long varchar进行比较。
Derby issue about this already registered
建议:
根据您的数据,我建议使用varchar或CLOB而不是long varchar。