예제 #1
0
 @Override
 public void manageException(SQLException ex)
     throws ExceptionDBDuplicateEntry, ExceptionDBEntryReferencedElsewhere {
   // TODO: This is a hack (is it???)
   String message = ex.getMessage().toLowerCase();
   if (message.contains("sqlite_constraint")) {
     if (message.contains("is not unique")) throw new ExceptionDBDuplicateEntry();
     else if (message.contains("foreign key constraint failed"))
       throw new ExceptionDBEntryReferencedElsewhere();
     else {
       DAOPackage.log(ex);
       throw new ExceptionDBUnknownError(ex);
     }
   } else {
     DAOPackage.log(ex);
     throw new ExceptionDBUnknownError(ex);
   }
 }
예제 #2
0
  @Override
  public String getBetweenExpression(String fieldName, Object d1, Object d2) {
    String filter = "";
    try {
      Date dd1 = null;
      Date dd2 = null;

      SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd");
      if (d1 instanceof String) dd1 = df.parse((String) d1);
      else dd1 = (Date) d1;
      if (d2 instanceof String) dd2 = df.parse((String) d2);
      else dd2 = (Date) d2;

      // TODO: Adicionar un dia a la fecha final???

      filter = fieldName + " >= " + dd1.getTime() + " AND " + fieldName + " <= " + dd2.getTime();
    } catch (ParseException ex) {
      DAOPackage.log(ex);
      // Logger.getLogger(VariationSQLite.class.getName()).log(Level.SEVERE, null, ex);
      throw new ExceptionDBUnknownError(ex);
    }

    return filter;
  }