The code below shows how to modify data in a database table using PreparedStatement.

Java Code:
PreparedStatement prepstmt;
try {     
  prepstmt = theConn.prepareStatement
   ("UPDATE tCust SET custName = ? "+
    " WHERE custId = ?");
  prepstmt.setString(1,"Smith");       
  prepstmt.setString(2, cust_id.getText());
  prepstmt.executeUpdate();
             
  theConn.commit();
  prepstmt.close();
  }
catch (Exception e) {
  e.printStackTrace();
}