calculating sum of rows and set to JLabel.


try
        {
         Connection con=new Connection();
            java.sql.Connection co=con.connectit();
            PreparedStatement pst=co.prepareStatement("select SUM(AmountRecieved),SUM(Total),SUM(Total)-SUM(AmountRecieved) as DueBalance from strech");
            ResultSet rs=pst.executeQuery();
            while(rs.next())
            {
                jLabel40.setText(""+rs.getDouble(2));
                jLabel42.setText(""+rs.getDouble(1));
                jLabel44.setText(""+rs.getDouble(3));
            }
            co.close();
            pst.close();
        }
            catch(Exception e)
                    {
                    System.out.println(e);
                    }

Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.