Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void auto(){
- ActionListener taskPerformer = new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- autosms();
- kirimotomatis(); /// isi methodnya ada dibawah
- }
- };
- new javax.swing.Timer(1000, taskPerformer).start();
- }
- //// ini method ngmbil data dari database dan
- public void kirimotomatis(){
- try {
- java.util.Date skrg = new java.util.Date();
- java.text.SimpleDateFormat kal = new
- java.text.SimpleDateFormat("dd/MM/yyyy");
- String tglsekarang=kal.format(skrg);
- // SET JAM
- Calendar cal=Calendar.getInstance();
- SimpleDateFormat jams=new SimpleDateFormat("HH:mm");
- String t=jams.format(cal.getTime());
- jLabel2.setText(t);
- try {
- String sql = "SELECT * FROM ustas WHERE proces ='false'";
- PreparedStatement pstat = con.prepareStatement(sql); // create a statement
- res=pstat.executeQuery();
- while (res.next())
- {
- String tglustas=res.getString("tanggal");
- String jamustas=res.getString("jam");
- String noustas=res.getString("nohp");
- String kett=res.getString("keterangan");
- String idustas=res.getString("id");
- try {
- if (tglsekarang.equals(tglustas)&&t.equals(jamustas)) {
- String query3 = "INSERT INTO outbox(DestinationNumber, TextDecoded,CreatorID) VALUES ('"+noustas+"', '"+kett+"','Gammu')";
- PreparedStatement hasil3=con.prepareStatement(query3);
- hasil3.executeUpdate();
- // ubah saldo 'processed' menjadi 'true' untuk setiap SMS yang telah diproses
- String query4 = "UPDATE ustas SET proces ='true' WHERE ID='"+idustas+"'";
- PreparedStatement hasil4=con.prepareStatement(query4);
- hasil4.executeUpdate();
- }else{
- }
- } catch (Exception e) {
- System.out.println("gtaot");
- }
- }
- // System.out.println("suksess");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- } catch (Exception e) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement