0

I am trying to dynamically add,delete and update records into a table

but i am getting following error.

java.lang.NullPointerException in preparedStatment object

i have tried this

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);
    }
Mehroz Irshad
  • 287
  • 1
  • 5
  • 14

0 Answers0