i need to update a table automatically after the insert of another table is successful. i am using prepared statement to do this, and tried couple of ways to do but dint work out. can some one please help me out on this. the code is given following
try
{
p=con.prepareStatement("insert into receipt values(?,?,?,?,?,?,?,?,?)");
p.setInt(1, rn);
p.setDate(2, new java.sql.Date(rd.getTime()));
p.setInt(3, ag);
p.setInt(4, an);
p.setString(5, name);
p.setString(6, street);
p.setString(7, city);
p.setInt(8, pinno);
p.setInt(9, ar);
p=con.prepareStatement("update loan set t_os=t_os-? where accno=?");
p.setInt(1, ar);
p.setInt(2, an);
p.executeUpdate();
/*try
{
p=con.prepareStatement("update loan set t_os=t_os-? where accno=?");
p.setInt(1, Integer.parseInt(art.getText()));
p.setInt(2, Integer.parseInt(ant.getText()));
p.executeUpdate();
}
catch(Exception e)
{
e.printStackTrace();
}*/
status.setForeground(Color.BLUE);
status.setText("Successfully Added");
}
catch (Exception e)
{
e.printStackTrace();
status.setForeground(Color.RED);
status.setText("Enter proper values");
}
for me it execution get stucks after p.executeUpdate();