這是我的程序給出的錯誤。 java.sql.SQLException:ORA-00001:唯一約束(SYSTEM.SYS_C006997)違反違反處理唯一約束(SYSTEM.SYS_C006997)
我試過以下代碼,但JOptionPane中的錯誤消息仍然不是「用戶存在」..我該怎麼做? 我也需要從我的程序執行提交語句來保存在oracle數據庫中創建的表?
try {
Statement stmt = con.createStatement();
stmt.executeUpdate("insert into users values('"+st1+"','"+st2+"')");
JOptionPane.showMessageDialog(null,"User Added","Message",JOptionPane.INFORMATION_MESSAGE);
setVisible(false);
src.addusr.main(null);
}
catch(SQLIntegrityConstraintViolationException e)
{
JOptionPane.showMessageDialog(null,"User Already Exists","Message",JOptionPane.ERROR_MESSAGE);
}
catch(SQLException e2) {
JOptionPane.showMessageDialog(null,e2.getMessage(),"Message",JOptionPane.ERROR_MESSAGE);
e2.printStackTrace();
}
try {
Statement stmt1 = con.createStatement();
stmt1.executeUpdate("commit");
}
catch(SQLException e6) {
e6.printStackTrace();
}
}
這可能是驅動程序特定的;您使用哪個驅動程序和版本連接到數據庫? – 2014-09-23 14:53:34
使用ojdbc14進行連接 – 2014-09-23 15:08:35