Compare commits
4 Commits
def32e81f0
...
4ec4fa5ee8
Author | SHA1 | Date |
---|---|---|
Lorenzo Bianchi | 4ec4fa5ee8 | |
Lorenzo Bianchi | 46f766644c | |
Lorenzo Bianchi | ac8c58c4e5 | |
Lorenzo Bianchi | 1fadd7032e |
|
@ -0,0 +1,2 @@
|
|||
- negli insert forse bisogna fare un setDate LB
|
||||
- al momento le disponibilità sono una al giorno senza orario (fate voi se avete voglia) LB
|
|
@ -3,8 +3,8 @@ import java.sql.SQLException;
|
|||
|
||||
public class Anagrafica extends Table{
|
||||
|
||||
public Anagrafica(Connection connection, String name, String statement) throws SQLException {
|
||||
super(connection, name, statement);
|
||||
public Anagrafica(Connection connection, String statement) throws SQLException {
|
||||
super(connection, statement);
|
||||
}
|
||||
|
||||
public void insert(UserData userdata) throws SQLException {
|
||||
|
@ -13,7 +13,7 @@ public class Anagrafica extends Table{
|
|||
stmt.setString(1, userdata.getCodiceFiscale());
|
||||
stmt.setString(2, userdata.getNome());
|
||||
stmt.setString(3, userdata.getCogNome());
|
||||
//stmt.setString(4, userdata.getDataNascita().toString());
|
||||
//TODO: stmt.setString(4, userdata.getDataNascita().toString());
|
||||
stmt.setString(4, userdata.getLuogoNascita());
|
||||
stmt.setLong(5, userdata.getNumFiscale());
|
||||
stmt.setString(6, userdata.getPassword());
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
public enum Attività {
|
||||
ritiro,
|
||||
pipi,
|
||||
bowling
|
||||
}
|
|
@ -13,30 +13,56 @@ public class Main {
|
|||
|
||||
//TODO: rimuovi gay e frocio
|
||||
|
||||
Anagrafica anagrafica = new Anagrafica(connection, "anagrafica", "CREATE TABLE IF NOT EXISTS anagrafica("
|
||||
PreparedStatement stmt;
|
||||
|
||||
stmt = connection.prepareStatement("DO $$ BEGIN "
|
||||
+ "CREATE TYPE categoria_appartenenza AS ENUM ('gay', 'frocio', 'down', 'edi', 'spastico');"
|
||||
+ "EXCEPTION "
|
||||
+ "WHEN duplicate_object THEN null; "
|
||||
+ "END $$;");
|
||||
stmt.execute();
|
||||
|
||||
stmt = connection.prepareStatement("DO $$ BEGIN "
|
||||
+ "CREATE TYPE attività AS ENUM ('ritiro', 'pipi', 'bowling');"
|
||||
+ "EXCEPTION "
|
||||
+ "WHEN duplicate_object THEN null; "
|
||||
+ "END $$;");
|
||||
stmt.execute();
|
||||
|
||||
Anagrafica anagrafica = new Anagrafica(connection, "CREATE TABLE IF NOT EXISTS anagrafica("
|
||||
+ "codice_fiscale VARCHAR(16) PRIMARY KEY,"
|
||||
+ "nome VARCHAR(16) NOT NULL,"
|
||||
+ "cognome VARCHAR(16) NOT NULL,"
|
||||
+ "data_nascita DATE,"
|
||||
+ "luogo_nascita VARCHAR(32),"
|
||||
+ "num_sanitario BIGINT,"
|
||||
+ "categorie_appartenenze VARCHAR(16)[],"
|
||||
+ "categorie_appartenenze categoria_appartenenza,"
|
||||
+ "password VARCHAR(16)"
|
||||
+ ")");
|
||||
|
||||
Prenotazioni prenotazioni = new Prenotazioni(connection, "CREATE TABLE IF NOT EXISTS prenotazioni("
|
||||
+ "num serial PRIMARY KEY,"
|
||||
+ "attività attività,"
|
||||
+ "data DATE,"
|
||||
+ "disponibilità boolean"
|
||||
+ ")");
|
||||
|
||||
UserData edi = new UserData("Edi", "DeCandido", "1234", new Data(20, 07, 2023), "Marte", 666, "fethergay");
|
||||
System.out.println(edi);
|
||||
|
||||
PreparedStatement stmt = connection.prepareStatement("DELETE FROM anagrafica");
|
||||
stmt = connection.prepareStatement("DELETE FROM anagrafica");
|
||||
stmt.execute();
|
||||
|
||||
anagrafica.insert(edi);
|
||||
|
||||
prenotazioni.insert(Attività.pipi, new Data(11, 11, 2023));
|
||||
|
||||
}
|
||||
|
||||
public boolean Registrazione(String nome, String cognome, String codice_fiscale, Data data_nascita, String luogo_nascita, String password) {
|
||||
//TODO: se l'utente è presente nel database di User_data, return true
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
public class Prenotazione {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Prenotazioni extends Table{
|
||||
|
||||
public Prenotazioni(Connection connection, String statement) throws SQLException {
|
||||
super(connection, statement);
|
||||
}
|
||||
|
||||
public void insert(Attività attività, Data data) throws SQLException {
|
||||
var stmt = connection.prepareStatement("INSERT INTO prenotazioni (attività, data, disponibilità) VALUES (?, '2000-10-10', TRUE)");
|
||||
|
||||
//TODO: qui attivita è soltanto una stringa ma serve un enum
|
||||
stmt.setObject(1, attività, java.sql.Types.OTHER);
|
||||
|
||||
//TODO: setDate forse? stmt.setString(2, data.toString());
|
||||
|
||||
System.out.println(stmt);
|
||||
|
||||
stmt.executeUpdate();
|
||||
}
|
||||
}
|
|
@ -3,11 +3,9 @@ import java.sql.SQLException;
|
|||
|
||||
public class Table {
|
||||
Connection connection;
|
||||
String name;
|
||||
|
||||
public Table(Connection connection, String name, String statement) throws SQLException {
|
||||
public Table(Connection connection, String statement) throws SQLException {
|
||||
this.connection = connection;
|
||||
this.name = name;
|
||||
this.execute(statement);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class UserData {
|
|||
this.luogo_nascita = luogo_nascita;
|
||||
this.codice_fiscale = codice_fiscale;
|
||||
this.num_sanitario = num_sanitario;
|
||||
// this.categoria_apparteneza = categoria_appartenenza;
|
||||
//TODO: this.categoria_apparteneza = categoria_appartenenza;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,4 @@ public class UserData {
|
|||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue