List of usage examples for org.springframework.dao TypeMismatchDataAccessException TypeMismatchDataAccessException
public TypeMismatchDataAccessException(String msg, Throwable cause)
From source file:org.seasar.doma.boot.autoconfigure.DomaPersistenceExceptionTranslator.java
@Override public DataAccessException translateExceptionIfPossible(RuntimeException ex) { if (!(ex instanceof JdbcException)) { // Fallback to other translators if not JdbcException return null; }// w ww .j av a 2 s. c o m if (ex instanceof OptimisticLockException) { return new OptimisticLockingFailureException(ex.getMessage(), ex); } else if (ex instanceof UniqueConstraintException) { return new DuplicateKeyException(ex.getMessage(), ex); } else if (ex instanceof NonUniqueResultException || ex instanceof NonSingleColumnException) { return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1, ex); } else if (ex instanceof NoResultException) { return new EmptyResultDataAccessException(ex.getMessage(), 1, ex); } else if (ex instanceof UnknownColumnException || ex instanceof ResultMappingException) { return new TypeMismatchDataAccessException(ex.getMessage(), ex); } if (ex.getCause() instanceof SQLException) { SQLException e = (SQLException) ex.getCause(); String sql = null; if (ex instanceof SqlExecutionException) { sql = ((SqlExecutionException) ex).getRawSql(); } return translator.translate(ex.getMessage(), sql, e); } return new UncategorizedDataAccessException(ex.getMessage(), ex) { }; }
From source file:org.lieuofs.util.dao.FichierOFSTxtDao.java
@PostConstruct public void chargerResource() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(fichier.getInputStream(), charsetName)); int numLigne = 1; String ligne = reader.readLine(); while (null != ligne) { try {//from w ww . j a v a 2s . c om traiterLigneFichier(ligne.split("\t")); } catch (ParseException pe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, pe); } catch (NumberFormatException nfe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, nfe); } ligne = reader.readLine(); numLigne++; } reader.close(); }
From source file:org.impotch.calcul.impot.cantonal.ge.pp.ChargeurFichierEconometre.java
/**************************************************/ public Object[][] charger(int periode, boolean famille) throws IOException { int anneeCouranteMoinsUn = Calendar.getInstance().get(Calendar.YEAR) - 1; if (periode < 1995 || periode > anneeCouranteMoinsUn) { logger.error("La priode fiscale " + periode + " n'est pas dfinie !"); throw new IllegalArgumentException("La priode fiscale " + periode + " n'est pas dfinie !"); }//from w w w.j a va2 s .c o m int indexImpot = 2 * (periode - 1995) + (famille ? 1 : 0) + 1; BufferedReader reader = new BufferedReader(new InputStreamReader(fichier.getInputStream())); int numLigne = 1; String ligne = reader.readLine(); List<Point> points = new LinkedList<Point>(); while (null != ligne) { try { String[] tokens = ligne.split(";"); String revenu = tokens[0].trim(); revenu = revenu.substring(0, revenu.length() - 1); if (Character.isDigit(revenu.charAt(0))) { points.add(new Point(revenu, tokens[indexImpot].trim())); } } catch (ParseException pe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, pe); } catch (NumberFormatException nfe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, nfe); } ligne = reader.readLine(); numLigne++; } reader.close(); Object[][] retour = new Object[points.size()][2]; int i = 0; for (Point pt : points) { retour[i][0] = pt.revenu; retour[i++][1] = pt.impot; } return retour; }
From source file:org.impotch.calcul.impot.cantonal.ge.param.dao.ParametreCommunalFichierTxtDao.java
/** * Lit le fichier texte et stocke les informations en mmoire. * //from w ww . j a v a2 s . c om * @throws IOException si une erreur survient durant la lecture */ @PostConstruct public void chargerResource() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(fichier.getInputStream(), charsetName)); int numLigne = 1; String ligne = reader.readLine(); while (null != ligne) { try { traiterLigneFichier(ligne.split("\t")); } catch (ParseException pe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, pe); } catch (NumberFormatException nfe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, nfe); } ligne = reader.readLine(); numLigne++; } reader.close(); }
From source file:org.impotch.calcul.impot.cantonal.ge.param.dao.ResidentParCommuneFichierTxtDao.java
/** * Lit le fichier texte et stocke les informations en mmoire. * * @throws java.io.IOException si une erreur survient durant la lecture *///from w w w. jav a 2 s . co m @PostConstruct public void chargerResource() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(fichier.getInputStream(), charsetName)); int numLigne = 1; String ligne = reader.readLine(); try { traiterPremiereLigneFichier(ligne.split(";")); } catch (ParseException pe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, pe); } catch (NumberFormatException nfe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, nfe); } numLigne = 2; ligne = reader.readLine(); while (null != ligne) { try { traiterLigneFichier(ligne.split(";")); } catch (ParseException pe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, pe); } catch (NumberFormatException nfe) { throw new TypeMismatchDataAccessException( "Erreur de lecture dans la ressource " + fichier.getFilename() + " la ligne " + numLigne, nfe); } ligne = reader.readLine(); numLigne++; } reader.close(); }
From source file:org.springframework.orm.toplink.SessionFactoryUtils.java
/** * Convert the given TopLinkException to an appropriate exception from the * <code>org.springframework.dao</code> hierarchy. * @param ex TopLinkException that occured * @return the corresponding DataAccessException instance *///from w w w.ja v a 2 s . c o m public static DataAccessException convertTopLinkAccessException(TopLinkException ex) { if (ex instanceof DatabaseException) { // SQLException during TopLink access: only passed in here from custom code, // as TopLinkTemplate will use SQLExceptionTranslator-based handling. return new TopLinkJdbcException((DatabaseException) ex); } if (ex instanceof OptimisticLockException) { return new TopLinkOptimisticLockingFailureException((OptimisticLockException) ex); } if (ex instanceof QueryException) { return new TopLinkQueryException((QueryException) ex); } if (ex instanceof ConcurrencyException) { return new ConcurrencyFailureException(ex.getMessage(), ex); } if (ex instanceof ConversionException) { return new TypeMismatchDataAccessException(ex.getMessage(), ex); } // fallback return new TopLinkSystemException(ex); }