OSDN Git Service

modified: build/classes/parauni/CommandController.class
[parauni/para-repos.git] / src / parauni / DataBase.java
index 8585bb7..483e987 100644 (file)
@@ -15,21 +15,26 @@ import java.util.regex.Pattern;
  */
 public class DataBase {
     String TASK_TBL = "task_tbl";
+       String VM_TBL = "vm_tbl";
     Connection con;
     Statement st;
 
-    public DataBase() throws SQLException{
+    public DataBase(){
         try {
             Class.forName("org.sqlite.JDBC");
-            con = DriverManager.getConnection("jdbc:sqlite:puc.db");
-            st = con.createStatement();
-            st.setQueryTimeout(1);
-            con.setAutoCommit(false);
-            
+                       try {
+                               con = DriverManager.getConnection("jdbc:sqlite:puc.db");
+                   st = con.createStatement();
+                       st.setQueryTimeout(1);
+                           con.setAutoCommit(false);
+                       } catch (SQLException ex) {
+                               Logger.getLogger(DataBase.class.getName()).log(Level.SEVERE, null, ex);
+                       }          
         } catch (ClassNotFoundException ex) {
             Logger.getLogger(DataBase.class.getName()).log(Level.SEVERE, null, ex);
         }
     }
+
     
     // データベースを初期化
     public void initDB() throws SQLException{
@@ -42,29 +47,40 @@ public class DataBase {
                 "SDATE datatime," +
                 "EDATE datatime," +
                 "OUTLINE string)");
-
-    
     }
+
     public void commit() throws SQLException{
         con.commit();
     }
 
-    public ResultSet executeQuery(String sql) throws SQLException{
-        ResultSet rs = st.executeQuery(sql);
+    public ResultSet executeQuery(String sql){
+      ResultSet rs;
+      try {
+        rs = st.executeQuery(sql);
         return rs;
+      } catch (SQLException ex) {
+        Logger.getLogger(DataBase.class.getName()).log(Level.SEVERE, null, ex);
+      }
+      return null;
     }
             
 
-    public int executeUpdate(String sql) throws SQLException{
-        Connection con = DriverManager.getConnection("jdbc:sqlite:puc.db");
-        Statement st = con.createStatement();
+    public int executeUpdate(String sql){
+      try {
         return st.executeUpdate(sql);
+      } catch (SQLException ex) {
+        Logger.getLogger(DataBase.class.getName()).log(Level.SEVERE, null, ex);
+      }
+      return -1;
     }
 
-    public void close() throws SQLException{
-        Connection con = DriverManager.getConnection("jdbc:sqlite:puc.db");
-        Statement st = con.createStatement();
+    public void close(){
+      try {
+        con.close();
         st.close();
+      } catch (SQLException ex) {
+        Logger.getLogger(DataBase.class.getName()).log(Level.SEVERE, null, ex);
+      }  
     }
 
     public boolean isDate(String date){