0
私はjtableとrs2xml.jarライブラリを使用していますjtableからの行の合計を計算する
私のテーブルは3列です。 ID、名前、金額 金額の合計を計算したい。
//showcal is my table name
try {
Connection conn = getConnection();
PreparedStatement ps
= conn.prepareStatement("select id,name,amount from income where idate=?");
ps.setString(1,((JTextField) inpdatechosser.getDateEditor().getUiComponent()).getText());
rset = ps.executeQuery();
showcal.setModel(DbUtils.resultSetToTableModel(rset));
//sum calculation
int total = 0;
for (int i = 0; i < showcal.getRowCount(); i++){
int amount = Integer.parseInt(showcal.getValueAt(i, 3).toString());
total =total+ amount;
}
jTextField1.setText(""+Integer.toString(total));
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
何も起こら:ここ
はコードです。私は "3> = 3"を得ています。 その意味は何ですか?なぜそれが動作していないのですか?
はい...私はその部分を逃しています...ありがとう –