我正在尝试删除数据库中的一行,该行与JTextField
. 但是引发了一个异常,下面的代码没有告诉我为什么。我能做什么?
try{Class.forName("oracle.jdbc.OracleDriver");
PreparedStatement pstmnt;
try (
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","123")) {
pstmnt = conn.prepareStatement("delete from TEMP where matricRoll=?");
pstmnt.setString(1, matricRoll.getText());
pstmnt.executeUpdate();
conn.close();
pstmnt.close();
GI.setVisible(true);
ED.setVisible(false);
addingToFrame();
settingBounds();
} catch (SQLException ex) {JOptionPane.showMessageDialog(null,"error");}
} catch (ClassNotFoundException ex) {
}
感谢您的所有关注……我发现了错误……我正在从无效的列中删除……这是解决方案……
try{
Class.forName("oracle.jdbc.OracleDriver");
Connection conn;
PreparedStatement pstmnt;
try (conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","123"))
{
pstmnt = conn.prepareStatement("delete from TEMP where MATRICRN=?");
String roll=matricRoll.getText();
int rollm=Integer.valueOf(roll);
pstmnt.setInt(1, rollm);
pstmnt.executeUpdate();
JOptionPane.showMessageDialog(null,"Deleted");
conn.close();
pstmnt.close();
GI.setVisible(true);
ED.setVisible(false);
addingToFrame();
settingBounds();
}
catch (SQLException ex)
{JOptionPane.showMessageDialog(null,"error"+ex);}
}
catch (ClassNotFoundException exe) {
JOptionPane.showMessageDialog(null,exe); }
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句