Im trying to insert data from jtable to database!! the first three columns(stafftimetableid,staffname,staffid) are inserted from the jtexfield(no errors found,successfully added) but when im trying to insert from jtable it promts a java.null pointerExcetion error !!
I have no errors in database connection !!
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if (jComboBox1.getSelectedItem().equals("Staff Time Table"))
{
try
{
PreparedStatement pst =null;
Connection con = clerkpanell.DBConnection.connectDB();
String data=jTable2.getValueAt(0,1).toString();
String sql = "insert into stafftimetable (StaffTimeTableID,StaffName,StaffID,7.50-8.30) values ('"+ttid.getText()+"','"+staffname.getText()+"','"+staffid.getText()+"','"+data+"');";
pst=con.prepareStatement(sql);
pst.executeUpdate();
// JOptionPane.showMessageDialog(null,"Added");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,e);
}
}