Buongiorno sto realizzando l'iscrizione con MVC in java swing e database sql (pgAdmin4) ma ho un problema tutto funziona ma nella tabella sql non mi vengono caricati i dati potete aiutarmi vi inserisco il codice relativo alla registrazione:
Potete aiutami?
Grazie mille
Java:
public class DaoUtente {
public static boolean creaUtente(Utente utente) throws SQLException,Exception
{
final String INSERIMENTO = "INSERT INTO utenti(nome, cognome, email, password, NumeroTelefonico, DataDiNascita) VALUES (?,?,?,?,?,?)";
Connection conn = null;
PreparedStatement stmt = null;
if(effettua_accesso(utente.getEmail(),utente.getPassword()))
{
conn = DBconnection.getInstance().getConn();
stmt = conn.prepareStatement(INSERIMENTO);
stmt.setString(1, utente.getNome());
stmt.setString(2, utente.getCognome());
stmt.setString(3, utente.getEmail());
stmt.setString(4, utente.getPassword());
stmt.setString(5, utente.getNumeroTelefonico());
stmt.setString(6, utente.getDataDiNascita());
stmt.executeUpdate();
stmt.close();
conn.close();
return true;
}
return false;
}
public static boolean effettua_accesso(String Email, String password) throws SQLException,Exception
{
final String RICERCA_PASSWORD="SELECT*FROM utenti where Email=? and password=?";
Connection conn = DBconnection.getInstance().getConn();
PreparedStatement stmt = conn.prepareStatement(RICERCA_PASSWORD);
stmt.setString(1, Email);
stmt.setString(2,password);
ResultSet rs=stmt.executeQuery();
if(!rs.next())
{
rs.close();
return false;
}
else
{
rs.close();
return true;
}
}
Java:
public void creaUtente(Utente utente)
{
if(inputVuoto(utente)==false){
{
try {
if(DaoUtente.creaUtente(utente))
{
VisualizzazioneErrore("Iscrizione Effettuata con successo");
}
else
{
VisualizzazioneErrore("Utente già presente");
}
} catch (SQLException e) {
VisualizzazioneErrore(e.getMessage() );
}
catch(Exception e)
{
VisualizzazioneErrore(e.getMessage());
}
}
}
else
{
VisualizzazioneErrore("alcuni campi sono vuoti");
}
}
SQL:
CREATE TABLE utenti
(
Id serial primary key
Nome character varing(25),
Cognome character varing(25),
Email character varing(25),
NumeroTelefonico character varing(25),
DataDiNascita character varing(25),
Password character varing(25)
);
Potete aiutami?
Grazie mille
Ultima modifica: