Query not work on method
I try to show on formated texfield the addition of DR and CR on my
database, this query cannot be execute. The following query is problematic
and no data displayed :
void jumlah(){
String kode_akun = (String) combo_kodeakun.getSelectedItem();
Date tgl1 = jDateChooser1.getDate();
Date tgl2 = jDateChooser2.getDate();
String query = "SELECT SUM(DEBET) AS D, SUM(KREDIT) AS K FROM
DETAIL_JURNAL "
+ "INNER JOIN JURNAL ON JURNAL.NO_JURNAL =
DETAIL_JURNAL.NO_JURNAL "
+ "WHERE JURNAL.TANGGAL BETWEEN '"+tgl1+"' AND
'"+tgl2+"' "
+ "AND DETAIL_JURNAL.KODE_AKUN = '"+kode_akun+"'";
try {
PreparedStatement ps = koneksi.getKoneksi().prepareStatement(query);
ResultSet rs = ps.executeQuery();
if(rs.next()){
txt_jumlahdebet.setValue(rs.getDouble("D"));
txt_jumlahkredit.setValue(rs.getDouble("K"));
}
} catch (SQLException ex) {
Logger.getLogger(panel_generalledger.class.getName()).log(Level.SEVERE,
null, ex);
}
}
But, this following query can be executed and the data shown are all
existing data :
void jumlah(){
String kode_akun = (String) combo_kodeakun.getSelectedItem();
Date tgl1 = jDateChooser1.getDate();
Date tgl2 = jDateChooser2.getDate();
String query = "SELECT SUM(DEBET) AS D, SUM(KREDIT) AS K FROM
DETAIL_JURNAL ";
try {
PreparedStatement ps = koneksi.getKoneksi().prepareStatement(query);
ResultSet rs = ps.executeQuery();
if(rs.next()){
txt_jumlahdebet.setValue(rs.getDouble("D"));
txt_jumlahkredit.setValue(rs.getDouble("K"));
}
} catch (SQLException ex) {
Logger.getLogger(panel_generalledger.class.getName()).log(Level.SEVERE,
null, ex);
}
}
I would like to query the first work with the data shown is the filter
data based on combobox and date.
Please help. Thanks
No comments:
Post a Comment