Exemple #1
0
    public MetadataBlob[] select(String selectString) {
      PreparedStatement stmt = null;
      try {
        stmt =
            conn.prepareStatement(
                "select writingKey, mapkey, blobdata from metadatablobs " + selectString + ";");
        ResultSet rs = stmt.executeQuery();
        List<MetadataBlob> list = new ArrayList<MetadataBlob>();
        while (rs.next()) {
          MetadataBlob f =
              new MetadataBlob(
                  rs.getString("writingkey"), rs.getString("mapkey"), rs.getString("blobdata"));
          list.add(f);
        }

        return list.toArray(new MetadataBlob[0]);
      } catch (SQLException sqe) {
        System.err.println("Error selecting: " + selectString);
        sqe.printStackTrace();
        return null;
      } finally {
        if (stmt != null)
          try {
            stmt.close();
          } catch (SQLException sqe2) {
            sqe2.printStackTrace();
          }
      }
    }
Exemple #2
0
 public boolean delete(String table, String deleteString) {
   Statement stmt = null;
   try {
     stmt = conn.createStatement();
     stmt.executeUpdate("delete from " + table + " where " + deleteString + ";");
     return true;
   } catch (SQLException sqe) {
     sqe.printStackTrace();
     return false;
   } finally {
     if (stmt != null)
       try {
         stmt.close();
       } catch (SQLException sqe2) {
         sqe2.printStackTrace();
       }
   }
 }
Exemple #3
0
 public boolean delete() {
   Statement stmt = null;
   try {
     stmt = conn.createStatement();
     stmt.executeUpdate(deleteStatement());
     return true;
   } catch (SQLException sqe) {
     System.err.println(deleteStatement());
     sqe.printStackTrace();
     return false;
   } finally {
     if (stmt != null)
       try {
         stmt.close();
       } catch (SQLException sqe2) {
         sqe2.printStackTrace();
       }
   }
 }
Exemple #4
0
 public boolean insert() {
   PreparedStatement stmt = null;
   try {
     stmt = conn.prepareStatement(insertStatement());
     stmt.setString(1, this.name);
     stmt.setString(2, this.b64string);
     stmt.executeUpdate();
     return true;
   } catch (SQLException sqe) {
     sqe.printStackTrace();
     return false;
   } finally {
     if (stmt != null)
       try {
         stmt.close();
       } catch (SQLException sqe2) {
         sqe2.printStackTrace();
       }
   }
 }
Exemple #5
0
    public boolean delete() {
      PreparedStatement stmt = null;
      try {
        stmt = conn.prepareStatement("DELETE from metadatablobs where writingkey=? AND mapkey=?");

        stmt.setString(1, this.b64WritingKey);
        stmt.setString(2, this.b64mapkey);
        stmt.executeUpdate();
        return true;
      } catch (SQLException sqe) {
        sqe.printStackTrace();
        return false;
      } finally {
        if (stmt != null)
          try {
            stmt.close();
          } catch (SQLException sqe2) {
            sqe2.printStackTrace();
          }
      }
    }
Exemple #6
0
    public boolean insert() {
      PreparedStatement stmt = null;
      try {
        stmt =
            conn.prepareStatement(
                "INSERT OR REPLACE INTO staticdata (name, staticdata) VALUES(?, ?)");

        stmt.setString(1, this.name);
        stmt.setString(2, this.b64string);
        stmt.executeUpdate();
        return true;
      } catch (SQLException sqe) {
        sqe.printStackTrace();
        return false;
      } finally {
        if (stmt != null)
          try {
            stmt.close();
          } catch (SQLException sqe2) {
            sqe2.printStackTrace();
          }
      }
    }
Exemple #7
0
 public RowData[] select() {
   PreparedStatement stmt = null;
   try {
     stmt = conn.prepareStatement(selectStatement());
     ResultSet rs = stmt.executeQuery();
     List<RowData> list = new ArrayList<>();
     while (rs.next()) {
       String username = rs.getString("name");
       String b64string = rs.getString(b64DataName());
       list.add(new UserData(username, b64string));
     }
     return list.toArray(new RowData[0]);
   } catch (SQLException sqe) {
     sqe.printStackTrace();
     return null;
   } finally {
     if (stmt != null)
       try {
         stmt.close();
       } catch (SQLException sqe2) {
         sqe2.printStackTrace();
       }
   }
 }
Exemple #8
0
    public boolean insert() {
      PreparedStatement stmt = null;
      try {
        stmt =
            conn.prepareStatement(
                "INSERT OR REPLACE INTO metadatablobs (writingkey, mapkey, blobdata) VALUES(?, ?, ?)");

        stmt.setString(1, this.b64WritingKey);
        stmt.setString(2, this.b64mapkey);
        stmt.setString(3, this.b64blobdata);
        stmt.executeUpdate();
        return true;
      } catch (SQLException sqe) {
        sqe.printStackTrace();
        return false;
      } finally {
        if (stmt != null)
          try {
            stmt.close();
          } catch (SQLException sqe2) {
            sqe2.printStackTrace();
          }
      }
    }