Esempio n. 1
0
  public static void update(Dia dia) {
    Connector.connect();
    Connector.update(
        "UPDATE dia SET iddia = " + dia.getIdDia() + ", data ='" + dia.getData() + "';");

    Connector.close();
  }
Esempio n. 2
0
 public static Dia read(Date data) {
   Dia dia = null;
   Connector.connect();
   ResultSet resultSet = Connector.query("SELECT * FROM dia WHERE data ='" + data + "';");
   try {
     if (resultSet.next()) {
       dia = new Dia();
       dia.setIdDia(resultSet.getLong("iddia"));
       dia.setData(resultSet.getDate("data"));
     }
   } catch (Exception e) {
     System.out.println(e.getMessage());
   }
   Connector.close();
   return dia;
 }
Esempio n. 3
0
  public static void create(Dia dia) {

    Connector.connect();
    Connector.update("INSERT INTO dia (data)" + " VALUES ('" + dia.getData() + "'); ");

    Connector.close();
  }
Esempio n. 4
0
 public static ArrayList<Dia> getAll() {
   ArrayList<Dia> lista = new ArrayList<Dia>();
   Dia dia = null;
   Connector.connect();
   ResultSet resultSet = Connector.query("SELECT * FROM dia;");
   try {
     while (resultSet.next()) {
       dia = new Dia();
       dia.setIdDia(resultSet.getLong("iddia"));
       dia.setData(resultSet.getDate("data"));
       lista.add(dia);
     }
   } catch (Exception e) {
     System.out.println(e.getMessage());
   }
   Connector.close();
   return lista;
 }