diff --git a/lib/mariadb-java-client-3.5.6.jar b/lib/mariadb-java-client-3.5.6.jar new file mode 100644 index 0000000..447793c Binary files /dev/null and b/lib/mariadb-java-client-3.5.6.jar differ diff --git a/src/fr/iutfbleau/papillon/Main.java b/src/fr/iutfbleau/papillon/Main.java new file mode 100644 index 0000000..e69de29 diff --git a/src/fr/iutfbleau/papillon/model/BaseDeDonnees.java b/src/fr/iutfbleau/papillon/model/BaseDeDonnees.java new file mode 100644 index 0000000..ddcfdad --- /dev/null +++ b/src/fr/iutfbleau/papillon/model/BaseDeDonnees.java @@ -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(); + } + } +} \ No newline at end of file diff --git a/src/fr/iutfbleau/papillon/model/DbConnexion.java b/src/fr/iutfbleau/papillon/model/DbConnexion.java deleted file mode 100644 index c0be256..0000000 --- a/src/fr/iutfbleau/papillon/model/DbConnexion.java +++ /dev/null @@ -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); - } -} \ No newline at end of file diff --git a/src/fr/iutfbleau/papillon/model/Rappel.java b/src/fr/iutfbleau/papillon/model/Rappel.java index 3f4fc7a..4efb062 100644 --- a/src/fr/iutfbleau/papillon/model/Rappel.java +++ b/src/fr/iutfbleau/papillon/model/Rappel.java @@ -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; } -} \ No newline at end of file + 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; + } + +}