Beispiel #1
0
  private synchronized void init() throws SQLException {
    if (isClosed) return;

    // do tables exists?
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(TABLE_NAMES_SELECT_STMT);

    ArrayList<String> missingTables = new ArrayList(TABLES.keySet());
    while (rs.next()) {
      String tableName = rs.getString("name");
      missingTables.remove(tableName);
    }

    for (String missingTable : missingTables) {
      try {
        Statement createStmt = conn.createStatement();
        // System.out.println("Adding table "+ missingTable);
        createStmt.executeUpdate(TABLES.get(missingTable));
        createStmt.close();

      } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
      }
    }
  }
Beispiel #2
0
 static {
   TABLES.put("users", CREATE_USERS_TABLE);
   TABLES.put("staticdata", CREATE_STATIC_DATA_TABLE);
   TABLES.put("followrequests", CREATE_FOLLOW_REQUESTS_TABLE);
   TABLES.put("metadatablobs", CREATE_METADATA_BLOBS_TABLE);
 }