diff --git a/persistence/src/main/java/fr/gasser/daoexample/DummyConnection.java b/persistence/src/main/java/fr/gasser/daoexample/DummyConnection.java deleted file mode 100644 index 3f72644..0000000 --- a/persistence/src/main/java/fr/gasser/daoexample/DummyConnection.java +++ /dev/null @@ -1,5 +0,0 @@ -package fr.gasser.daoexample; - -public class DummyConnection { - -} diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java index 5e262f5..fe3b9fe 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/Dao.java @@ -1,15 +1,15 @@ package fr.gasser.daoexample.dao; -import fr.gasser.daoexample.DummyConnection; import fr.gasser.daoexample.model.Entity; +import fr.gasser.daoexample.sql.Connection; import java.util.List; public abstract class Dao { - protected DummyConnection connection; + protected Connection connection; - public Dao(DummyConnection connection) { + public Dao(Connection connection) { this.connection = connection; } diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java b/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java index c258b5d..606f263 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/DaoFactory.java @@ -1,9 +1,10 @@ package fr.gasser.daoexample.dao; -import fr.gasser.daoexample.DummyConnection; +import fr.gasser.daoexample.sql.Connection; +import fr.gasser.daoexample.sql.DummyConnection; public class DaoFactory implements DaoAbstractFactory { - private static DummyConnection connection = new DummyConnection(); + private static Connection connection = new DummyConnection(); @Override public StudentDao createStudentDao() { diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java index fc52a23..61ac979 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/DisciplineDao.java @@ -1,7 +1,7 @@ package fr.gasser.daoexample.dao; -import fr.gasser.daoexample.DummyConnection; import fr.gasser.daoexample.model.Discipline; +import fr.gasser.daoexample.sql.Connection; import java.util.ArrayList; import java.util.Arrays; @@ -16,7 +16,7 @@ public class DisciplineDao extends Dao { new Discipline(2, "Qsdf") )); - public DisciplineDao(DummyConnection connection) { + public DisciplineDao(Connection connection) { super(connection); } diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java index 3df5427..34b0c5c 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/StudentDao.java @@ -1,7 +1,7 @@ package fr.gasser.daoexample.dao; -import fr.gasser.daoexample.DummyConnection; import fr.gasser.daoexample.model.Student; +import fr.gasser.daoexample.sql.Connection; import java.util.ArrayList; import java.util.Arrays; @@ -16,7 +16,7 @@ public class StudentDao extends Dao { new Student(2, "Qsdf", "Jklm")) ); - StudentDao(DummyConnection connection) { + StudentDao(Connection connection) { super(connection); } diff --git a/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java b/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java index c10b644..8becfa0 100644 --- a/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java +++ b/persistence/src/main/java/fr/gasser/daoexample/dao/TeacherDao.java @@ -1,7 +1,7 @@ package fr.gasser.daoexample.dao; -import fr.gasser.daoexample.DummyConnection; import fr.gasser.daoexample.model.Teacher; +import fr.gasser.daoexample.sql.Connection; import java.util.ArrayList; import java.util.Arrays; @@ -16,7 +16,7 @@ public class TeacherDao extends Dao { new Teacher(2, "Sit", "Amet")) ); - TeacherDao(DummyConnection connection) { + TeacherDao(Connection connection) { super(connection); } diff --git a/persistence/src/main/java/fr/gasser/daoexample/sql/Connection.java b/persistence/src/main/java/fr/gasser/daoexample/sql/Connection.java new file mode 100644 index 0000000..36ac760 --- /dev/null +++ b/persistence/src/main/java/fr/gasser/daoexample/sql/Connection.java @@ -0,0 +1,9 @@ +package fr.gasser.daoexample.sql; + +public interface Connection { + void connect(); + + void close(); + + java.sql.Connection getConnection(); +} diff --git a/persistence/src/main/java/fr/gasser/daoexample/sql/DummyConnection.java b/persistence/src/main/java/fr/gasser/daoexample/sql/DummyConnection.java new file mode 100644 index 0000000..936647e --- /dev/null +++ b/persistence/src/main/java/fr/gasser/daoexample/sql/DummyConnection.java @@ -0,0 +1,18 @@ +package fr.gasser.daoexample.sql; + +public class DummyConnection implements Connection { + @Override + public void connect() { + + } + + @Override + public void close() { + + } + + @Override + public java.sql.Connection getConnection() { + return null; + } +}