コード例 #1
0
 public boolean query(String sql) {
   try {
     Statement stmt = getStatement();
     if (stmt != null) stmt.close();
     ResultSet rs = getResultSet();
     if (rs != null) rs.close();
     Connection con = getConnection();
     if (con == null) return false;
     stmt = con.createStatement();
     setStatement(stmt);
     rs = stmt.executeQuery(sql);
     setResultSet(rs);
   } catch (Exception e) {
     Debug.warning(e);
     return false;
   }
   return true;
 }
コード例 #2
0
 public int update(String sql) {
   int numOfUpdated = 0;
   try {
     Statement stmt = getStatement();
     if (stmt != null) {
       stmt.close();
       setStatement(null);
     }
     ResultSet rs = getResultSet();
     if (rs != null) {
       rs.close();
       setResultSet(null);
     }
     Connection con = getConnection();
     if (con == null) return 0;
     stmt = con.createStatement();
     numOfUpdated = stmt.executeUpdate(sql);
     stmt.close();
   } catch (Exception e) {
     Debug.warning(e);
   }
   return numOfUpdated;
 }