我正在尝试动态添加,删除和更新记录到表
但我收到了以下错误。
preparedStatment对象中的java.lang.NullPointerException
我试过这个
try {
String sql = "INSERT INTO " + LoginFrame.userName + "." + TableInfo.tableName + "(" + txtIdName.getText() + "," + txtName.getText() + ") VALUES(?,?)";
JOptionPane.showMessageDialog(null, sql);
pst = (OraclePreparedStatement)con.prepareStatement(sql);
pst.setInt(1, Integer.parseInt(txtIdValue.getText()));
pst.setString(2, txtValue.getText());
pst.executeUpdate();
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
System.out.println(ex);
}