Sum of database field and set on JTable.
try
{
Connection c=new Connection();
java.sql.Connection con=c.connectit();
String sql="select SUM(Quantity) from stock where Category='s'";
PreparedStatement pst=con.prepareStatement(sql);
ResultSet rs=pst.executeQuery(sql);
while(rs.next())
{
jLabel6.setText(""+rs.getInt(1));
}
con.close();
pst.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}