Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code> I think this may help you </code></pre> <p>private void pay_saveActionPerformed(java.awt.event.ActionEvent evt) {<br> String dbUrl = "jdbc:mysql://localhost/hostel"; String dbClass = "com.mysql.jdbc.Driver"; PreparedStatement ps1 = null;</p> <p>try { Class.forName("com.mysql.jdbc.Driver");</p> <pre><code> con = DriverManager.getConnection (dbUrl,"root","17121990"); System.out.println("connected!"); String firstname=pay_enter_firstname.getText(); String lastname=pay_enter_lastname.getText(); String amt=pay_enter_amt.getText(); int amount=Integer.parseInt(amt); String day=pay_enter_date.getText(); String cheque_no=pay_enter_chequeno.getText(); String mode=pay_enter_mode.getText(); int totalamount=10000; int bal_amt=totalamount-amount; String remark=pay_enter_remark.getText(); int id = Integer.parseInt(pay_enter_id.getText()); Statement stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery("SELECT id, lastamtreceived FROM payment"); if(rs.next()) { stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery("SELECT id, lastamtreceived FROM payment"); while(rs.next()) { int temp =rs.getInt(1); if (temp ==id) { int amtrecvd2= rs.getInt(2); bal_amt=totalamount- (amtrecvd2+amount); String updt = "UPDATE payment SET Amountreceivd="+(amtrecvd2+amount)+",lastamtreceived="+amount+",dte='"+day+"', balance_amt ="+bal_amt+" WHERE id ="+temp+";" ; Statement stmt1 = con.createStatement(); int result = stmt1.executeUpdate(updt); } } } else { String str=" INSERT INTO payment(id, firstname,lastname,Amountreceivd,dte,lastamtreceived,Creditcashcheque," + "cheque_no,balance_amt,totalamount,Remark) VALUES ("+id+",'"+firstname+"','"+lastname+"',"+amount+",'"+day+"',"+amount+",'"+mode+"','"+cheque_no+"',"+ bal_amt+","+totalamount+",'"+remark+"')"; Statement stmt1=con.createStatement(); int result=stmt1.executeUpdate(str); panel_feesframe.setVisible(false); } panel_feesframe.setVisible(false); </code></pre> <p>con.close(); } catch (ClassNotFoundException | SQLException | NumberFormatException e) { e.printStackTrace(); }</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload