ajout model BaseDeDonnees et Rappel
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package fr.iutfbleau.papillon.model;
|
||||
import org.mariadb.jdbc.MariaDbDataSource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class BaseDeDonnees {
|
||||
|
||||
private static Connection connexion;
|
||||
|
||||
public static Connection getConnexion() {
|
||||
if (connexion == null) {
|
||||
try {
|
||||
MariaDbDataSource dataSource = new MariaDbDataSource();
|
||||
dataSource.setUrl("jdbc:mariadb://localhost:3307/papillon");
|
||||
dataSource.setUser("root");
|
||||
dataSource.setPassword("mdp");
|
||||
|
||||
connexion = dataSource.getConnection();
|
||||
System.out.println(" Connexion réussie !");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return connexion;
|
||||
}
|
||||
|
||||
public static void fermer() {
|
||||
try {
|
||||
if (connexion != null && !connexion.isClosed()) {
|
||||
connexion.close();
|
||||
System.out.println(" Connexion fermée.");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
|
||||
public class DbConnexion {
|
||||
private static final String URL = "jdbc:mariadb://dwarves.iut-fbleau.fr/---";
|
||||
private static final String USER = "login";
|
||||
private static final String PASSWORD = "mdp";
|
||||
|
||||
public static Connection getConnection() throws SQLException {
|
||||
try {
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new SQLException("Pilote MariaDB non trouvé.", e);
|
||||
}
|
||||
return DriverManager.getConnection(URL, USER, PASSWORD);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
package model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
package fr.iutfbleau.papillon.model;
|
||||
|
||||
public class Rappel {
|
||||
private int id;
|
||||
@@ -14,4 +12,24 @@ public class Rappel {
|
||||
this.contenu = contenu;
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
public Rappel(String titre, String contenu, String theme, int rang){
|
||||
this(0,titre,contenu,theme,rang);
|
||||
}
|
||||
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
public String getTitre(){
|
||||
return titre;
|
||||
}
|
||||
public String getContenu(){
|
||||
return contenu;
|
||||
}
|
||||
public String getTheme(){
|
||||
return theme;
|
||||
}
|
||||
public int getRang(){
|
||||
return rang;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user