Codigo DAO:
public void calcula(Cheque x1) throws SQLException {
String sql = "select sum(valor) as Total from cheque where datapag between datapag=? and datapag=?";
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setString(1, x1.getValor());
stmt.setString(2, x1.getDatapag());
stmt.execute();
stmt.close();
}
codigo programa:
[code]
public void calcular() {
try {
Cheque x1 = cheques.get(jTabelacheque.getSelectedRow());
x1.setDatapag(jTdatacalculo1.getText());
x1.setDatapag(jTdatacalculo2.getText());
ChequeDao dao = new ChequeDao();
dao.calcula(x1);
} catch (SQLException ex) {
Logger.getLogger(jTCheque.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jBCalcularActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int resp2 = JOptionPane.showConfirmDialog(this, "Deseja realmente alterar este cliente?",
"Confirmação", JOptionPane.YES_NO_OPTION);
if(resp2 == JOptionPane.YES_NO_OPTION){
calcular();
JOptionPane.showConfirmDialog(this,"total");
}
}[/code]
eu queria retornar o resultado do banco em uma janela, é possivel?