private List<Medication> searchRegnr(String lang, String regnr) {
    List<Medication> med_auth = new ArrayList<>();

    try {
      Connection conn = lang.equals("de") ? german_db.getConnection() : french_db.getConnection();
      Statement stat = conn.createStatement();
      String query =
          "select "
              + SHORT_TABLE
              + " from "
              + DATABASE_TABLE
              + " where "
              + KEY_REGNRS
              + " like "
              + "'%, "
              + regnr
              + "%' or "
              + KEY_REGNRS
              + " like "
              + "'"
              + regnr
              + "%'";
      ResultSet rs = stat.executeQuery(query);
      if (rs != null) {
        while (rs.next()) {
          med_auth.add(cursorToShortMedi(rs));
        }
      }
      conn.close();
    } catch (SQLException e) {
      System.err.println(">> SqlDatabase: SQLException in searchRegnr!");
    }

    return med_auth;
  }
  private List<Medication> searchName(String lang, String name) {
    List<Medication> med_titles = new ArrayList<>();

    try {
      Connection conn = lang.equals("de") ? german_db.getConnection() : french_db.getConnection();
      Statement stat = conn.createStatement();
      ResultSet rs;
      // Allow for search to start inside a word...
      if (name.length() > 2) {
        String query =
            "select "
                + SHORT_TABLE
                + " from "
                + DATABASE_TABLE
                + " where "
                + KEY_TITLE
                + " like "
                + "'"
                + name
                + "%' or "
                + KEY_TITLE
                + " like "
                + "'%"
                + name
                + "%'";
        rs = stat.executeQuery(query);
      } else {
        String query =
            "select "
                + SHORT_TABLE
                + " from "
                + DATABASE_TABLE
                + " where "
                + KEY_TITLE
                + " like "
                + "'"
                + name
                + "%'";
        rs = stat.executeQuery(query);
      }
      if (rs != null) {
        while (rs.next()) {
          med_titles.add(cursorToShortMedi(rs));
        }
      }
      conn.close();
    } catch (SQLException e) {
      System.err.println(">> SqlDatabase: SQLException in searchName for " + name);
    }

    return med_titles;
  }
 private Medication getMedicationWithId(String lang, long rowId) {
   try {
     Connection conn = lang.equals("de") ? german_db.getConnection() : french_db.getConnection();
     Statement stat = conn.createStatement();
     String query = "select * from " + DATABASE_TABLE + " where " + KEY_ROWID + "=" + rowId;
     ResultSet rs = stat.executeQuery(query);
     Medication m = cursorToMedi(rs);
     conn.close();
     if (m != null) return m;
   } catch (SQLException e) {
     System.err.println(">> SqlDatabase: SQLException in getContentWithId!");
   }
   return null;
 }
 private int numRecords(String lang) {
   int num_rec = -1;
   try {
     Connection conn = lang.equals("de") ? german_db.getConnection() : french_db.getConnection();
     Statement stat = conn.createStatement();
     String query = "select count(*) from amikodb";
     ResultSet rs = stat.executeQuery(query);
     num_rec = rs.getInt(1);
     conn.close();
   } catch (SQLException e) {
     System.err.println(">> SqlDatabase: SQLException in numRecords");
   }
   return num_rec;
 }
 private Medication getMedicationWithEan(String lang, String eancode) {
   try {
     Connection conn = lang.equals("de") ? german_db.getConnection() : french_db.getConnection();
     Statement stat = conn.createStatement();
     String search_key = KEY_PACKAGES;
     if (eancode.length() == 5) search_key = KEY_REGNRS;
     String query =
         "select * from "
             + DATABASE_TABLE
             + " where "
             + search_key
             + " like "
             + "'%"
             + eancode
             + "%'";
     ResultSet rs = stat.executeQuery(query);
     Medication m = cursorToMedi(rs);
     conn.close();
     if (m != null) return m;
   } catch (SQLException e) {
     System.err.println(">> SqlDatabase: SQLException in getContentWithId!");
   }
   return null;
 }