summaryrefslogtreecommitdiffstats
path: root/java/MyMyBatis/src/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/MyMyBatis/src/Main.java')
-rw-r--r--java/MyMyBatis/src/Main.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/java/MyMyBatis/src/Main.java b/java/MyMyBatis/src/Main.java
new file mode 100644
index 0000000..9e69b0d
--- /dev/null
+++ b/java/MyMyBatis/src/Main.java
@@ -0,0 +1,41 @@
+package ch.asynk;
+
+import java.util.List;
+
+public class Main
+{
+ public static void main(String [] args )
+ {
+ try {
+ ModelDAO.getSqlConnection().runScript("create.sql");
+ } catch (java.io.IOException e) {
+ System.err.println(e.getMessage());
+ }
+
+ ModelDAO dao = ModelDAO.getInstance();
+ Model m;
+ List<Model> models;
+
+ System.out.println("count : " + dao.count());
+ models = dao.select();
+ System.out.println("select : ");
+ for (Model _m : models) System.out.println(" - " +_m.toString());
+
+ m = dao.selectOne(2);
+ System.out.println("selectOne : " + m.toString());
+ System.out.println("update ...");
+ m.setName("adios");
+ dao.update(m);
+ m = dao.selectOne(2);
+ System.out.println("selectOne : " + m.toString());
+ System.out.println("delete : " + dao.delete(m));
+ System.out.println("count : " + dao.count());
+ System.out.println("insert ...");
+ m = new Model(-1, "HoMySatan");
+ dao.insert(m);
+ System.out.println("count : " + dao.count());
+ System.out.println("select : ");
+ models = dao.select();
+ for (Model _m : models) System.out.println(" - " +_m.toString());
+ }
+}