Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while(rs.next()){
- Vector<String> rowData = new Vector<>();
- rowData.add(rs.getString(1));
- rowData.add(rs.getString(2));
- rowData.add(rs.getString(3));
- model.addRow(rowData);
- }
- //after the loop count the sum of 3rd column
- int total=0;
- for (int i = 0; i < model.getRowCount(); i++){
- total +=Integer.parseInt( model.getValueAt(i, 2).toString() );// 3rd column . row column indexes are 0 based
- }
- System.out.println("sum of 3rd line is "+total);
Advertisement
Add Comment
Please, Sign In to add comment