*/
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{
"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){