Example usage for org.springframework.dao DataAccessException getMessage

List of usage examples for org.springframework.dao DataAccessException getMessage

Introduction

In this page you can find the example usage for org.springframework.dao DataAccessException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:com.sfs.whichdoctor.dao.SearchIndexDAOImpl.java

/**
 * Update the search index integer value.
 *
 * @param guid the guid// www . ja v a  2  s .c  o m
 * @param indextype the indextype
 * @param objectTypeId1 the object type id1
 * @param objectTypeId2 the object type id2
 * @param value the value
 *
 * @return true, if successful
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final boolean update(final int guid, final String indextype, final int objectTypeId1,
        final int objectTypeId2, final int value) throws WhichDoctorDaoException {

    boolean success = false;

    try {
        this.getJdbcTemplateWriter().update(this.getSQL().getValue("searchindex/numeric"),
                new Object[] { guid, indextype, objectTypeId1, objectTypeId2, value, value });

        success = true;

    } catch (DataAccessException de) {
        dataLogger.error("Error updating index: " + de.getMessage());
    }
    return success;
}

From source file:com.sfs.whichdoctor.dao.SearchIndexDAOImpl.java

/**
 * Update the search index double value.
 *
 * @param guid the guid/*  w w  w  .  j  a va2  s. com*/
 * @param indextype the indextype
 * @param objectTypeId1 the object type id1
 * @param objectTypeId2 the object type id2
 * @param value the value
 *
 * @return true, if successful
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final boolean update(final int guid, final String indextype, final int objectTypeId1,
        final int objectTypeId2, final double value) throws WhichDoctorDaoException {

    boolean success = false;

    try {
        this.getJdbcTemplateWriter().update(this.getSQL().getValue("searchindex/currency"),
                new Object[] { guid, indextype, objectTypeId1, objectTypeId2, value, value });

        success = true;

    } catch (DataAccessException de) {
        dataLogger.error("Error updating index: " + de.getMessage());
    }
    return success;
}

From source file:com.sfs.whichdoctor.dao.SearchIndexDAOImpl.java

/**
 * Update the search index string value.
 *
 * @param guid the guid//  w  w  w  .j  a v  a2 s  . com
 * @param indextype the indextype
 * @param objectTypeId1 the object type id1
 * @param objectTypeId2 the object type id2
 * @param value the value
 *
 * @return true, if successful
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final boolean update(final int guid, final String indextype, final int objectTypeId1,
        final int objectTypeId2, final String value) throws WhichDoctorDaoException {

    boolean success = false;

    try {
        this.getJdbcTemplateWriter().update(this.getSQL().getValue("searchindex/text"),
                new Object[] { guid, indextype, objectTypeId1, objectTypeId2, value, value });

        success = true;

    } catch (DataAccessException de) {
        dataLogger.error("Error updating index: " + de.getMessage());
    }
    return success;
}

From source file:no.uis.service.ws.studinfosolr.impl.FagpersonPushListener.java

private String getAnsattnummer(Fagperson person) {
    try {// www  . j a va  2s . co  m
        return employeeNumberResolver.findEmployeeNumber(person.getFnr());
    } catch (DataAccessException e) { // TODO dependency on Spring framework, is this good?
        StringBuilder sb = new StringBuilder();
        sb.append(e.getMessage());
        sb.append(": ");
        final Personnavn pn = person.getPersonnavn();
        sb.append(pn.getFornavn());
        sb.append(' ');
        sb.append(pn.getEtternavn());
        LOG.warn(sb.toString());
        return null;
    }
}

From source file:net.navasoft.madcoin.backend.services.security.ProviderDataAccess.java

/**
 * Load user by username./*w w w  . j  a v a  2s.  co m*/
 * 
 * @param username
 *            the username
 * @return the user details
 * @throws UsernameNotFoundException
 *             the username not found exception
 * @throws DataAccessException
 *             the data access exception
 * @throws BadConfigException
 *             the bad config exception
 * @since 31/08/2014, 07:23:59 PM
 */
@Override
public UserDetails loadUserByUsername(String username)
        throws UsernameNotFoundException, DataAccessException, BadConfigException {
    String key = defineKey(username);
    if (initializer.containsKey(key)) {
        try {
            mapping.addValue("username", username, Types.VARCHAR);
            User user = dao.queryForObject(initializer.getProperty(key), mapping, defineMapper(username));
            return user;
        } catch (DataAccessException dao) {
            if (dao instanceof EmptyResultDataAccessException) {
                throw new UsernameNotFoundException(dao.getMessage());
            } else {
                dao.printStackTrace();
                throw dao;
            }
        }
    } else {
        throw new BadConfigException("Query is not defined.");
    }
}

From source file:com.bt.aloha.dao.StateInfoDaoImpl.java

public void housekeep(String collectionTypeName, long maxTimeToLive, RowCallbackHandler rowCallBackHandler) {
    try {/*from  w w w  . ja va2s . co  m*/
        log.debug(String.format("Housekeeping: current number of objects in database is %d",
                size(collectionTypeName)));
        long houseKeepBefore = System.currentTimeMillis() - maxTimeToLive;
        Object[] params = new Object[] { houseKeepBefore, collectionTypeName };
        int[] types = new int[] { Types.BIGINT, Types.VARCHAR };
        int deleted = getJdbcTemplate().update(STATEINFO_DELETE_BY_HOUSEKEEPER_FLAGS_SQL, params, types);
        log.info(String.format("Removed %d objects from database", deleted));
        getJdbcTemplate().query(STATEINFO_SELECT_BY_HOUSEKEEPER_FLAGS_SQL, params, rowCallBackHandler);
        int updated = getJdbcTemplate().update(STATEINFO_UPDATE_BY_HOUSEKEEPER_FLAGS_SQL, params, types);
        log.info(String.format("Forced housekeeping on %d objects from database", updated));
    } catch (DataAccessException e) {
        log.error(String.format("Error occurred during database housekeeping: %s", e.getMessage()));
    }
}

From source file:pe.gob.mef.gescon.hibernate.impl.WikiDaoImpl.java

@Override
public List<HashMap> getConcimientosDisponibles(HashMap filters) {
    String ntipoconocimientoid = ((BigDecimal) filters.get("ntipoconocimientoid")).toString();
    String nconocimientovinc = (String) filters.get("nconocimientovinc");
    final StringBuilder sql = new StringBuilder();
    Object object = null;//from  w w w.  j a va 2s . co  m
    try {
        if (StringUtils.isNotBlank(ntipoconocimientoid) && ntipoconocimientoid.equals("1")) {
            sql.append("SELECT ");
            sql.append(
                    "    a.nbaselegalid AS ID, a.vnumero AS NUMERO, a.vnombre AS NOMBRE, a.vsumilla AS SUMILLA, ");
            sql.append(
                    "    a.ncategoriaid AS IDCATEGORIA, b.vnombre AS CATEGORIA, a.dfechapublicacion AS FECHA, ");
            sql.append(
                    "    1 AS IDTIPOCONOCIMIENTO, 'Base Legal' AS TIPOCONOCIMIENTO, a.nestadoid AS IDESTADO, c.vnombre AS ESTADO ");
            sql.append("FROM TBASELEGAL a ");
            sql.append("    INNER JOIN MTCATEGORIA b ON a.ncategoriaid = b.ncategoriaid ");
            sql.append("    INNER JOIN MTESTADO_BASELEGAL c ON a.nestadoid = c.nestadoid ");
            sql.append("WHERE a.nactivo = :ACTIVO ");
            sql.append("AND a.nestadoid IN (3,5,6) "); // Publicada, Concordada y Modificada.
            if (StringUtils.isNotBlank(nconocimientovinc)) {
                sql.append("AND a.nbaselegalid NOT IN (").append(nconocimientovinc).append(") ");
            }
        }
        if (StringUtils.isNotBlank(ntipoconocimientoid) && ntipoconocimientoid.equals("2")) {
            sql.append("SELECT ");
            sql.append("    a.npreguntaid AS ID, '' AS NUMERO, a.vasunto AS NOMBRE, a.vdetalle AS SUMILLA, ");
            sql.append(
                    "    a.ncategoriaid AS IDCATEGORIA, b.vnombre AS CATEGORIA, a.dfechacreacion AS FECHA, ");
            sql.append("    2 AS IDTIPOCONOCIMIENTO, 'Preguntas y Respuestas' AS TIPOCONOCIMIENTO, ");
            sql.append("    a.nsituacionid AS IDESTADO, c.vnombre AS ESTADO ");
            sql.append("FROM TPREGUNTA a ");
            sql.append("    INNER JOIN MTCATEGORIA b ON a.ncategoriaid = b.ncategoriaid ");
            sql.append("    INNER JOIN MTSITUACION c ON a.nsituacionid = c.nsituacionid ");
            sql.append("WHERE a.nactivo = :ACTIVO ");
            sql.append("AND a.nsituacionid = 6 "); // Publicado
            if (StringUtils.isNotBlank(nconocimientovinc)) {
                sql.append("AND a.npreguntaid NOT IN (").append(nconocimientovinc).append(") ");
            }
        }
        if (StringUtils.isNotBlank(ntipoconocimientoid)
                && (ntipoconocimientoid.equals("3") || ntipoconocimientoid.equals("4")
                        || ntipoconocimientoid.equals("5") || ntipoconocimientoid.equals("6"))) {
            sql.append("SELECT ");
            sql.append(
                    "    a.nconocimientoid AS ID, '' AS NUMERO, a.vtitulo AS NOMBRE, a.vdescripcion AS SUMILLA, ");
            sql.append(
                    "    a.ncategoriaid AS IDCATEGORIA, b.vnombre AS CATEGORIA, a.dfechacreacion AS FECHA, ");
            sql.append("    a.ntpoconocimientoid AS IDTIPOCONOCIMIENTO, d.vnombre AS TIPOCONOCIMIENTO, ");
            sql.append("    a.nsituacionid AS IDESTADO, c.vnombre AS ESTADO ");
            sql.append("FROM TCONOCIMIENTO a ");
            sql.append("    INNER JOIN MTCATEGORIA b ON a.ncategoriaid = b.ncategoriaid ");
            sql.append("    INNER JOIN MTSITUACION c ON a.nsituacionid = c.nsituacionid ");
            sql.append("    INNER JOIN MTTIPO_CONOCIMIENTO d ON a.ntpoconocimientoid = d.ntpoconocimientoid ");
            sql.append("WHERE a.nactivo = :ACTIVO ");
            sql.append("AND a.nsituacionid = 6 "); // Publicado
            if (StringUtils.isNotBlank(nconocimientovinc)) {
                sql.append("AND a.nconocimientoid NOT IN (").append(nconocimientovinc).append(") ");
            }
        }
        sql.append("ORDER BY 5, 7 DESC ");

        object = getHibernateTemplate().execute(new HibernateCallback() {
            @Override
            public Object doInHibernate(Session session) throws HibernateException {
                Query query = session.createSQLQuery(sql.toString());
                query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
                if (StringUtils.isNotBlank(sql.toString())) {
                    query.setParameter("ACTIVO", BigDecimal.ONE);
                }
                return query.list();
            }
        });
    } catch (DataAccessException e) {
        e.getMessage();
        e.printStackTrace();
    }
    return (List<HashMap>) object;
}

From source file:org.onesun.atomator.dao.OAuthResultDAOImpl.java

@Override
public void append(String user, OAuthResult entry, boolean update) {
    String query = "INSERT INTO " + AUTH_ENTRY_TABLE
            + " (identity, user_id, channel_name, access_key, access_secret, verification_code) "
            + " VALUES (?,?,?,?,?,?)";

    /**/*from  w w w.ja  va 2s . c  om*/
     * Specify the values 
     */
    try {
        Configuration.getJdbcTemplate().update(query,
                new Object[] { entry.getIdentity(), user, entry.getChannelName(), entry.getAccessKey(),
                        entry.getAccessSecret(), entry.getVerificationCode() });

        logger.info("Added Authentication Results for " + entry.getChannelName());
    } catch (DataAccessException e1) {
        if (e1.getCause().getMessage().contains(
                "integrity constraint violation: unique constraint or index violation; SYS_PK_10029")) {

            if (update == true) {
                query = "UPDATE " + AUTH_ENTRY_TABLE
                        + " SET access_key=?, access_secret=?, verification_code=? WHERE identity=?";

                try {
                    Configuration.getJdbcTemplate().update(query, new Object[] { entry.getAccessKey(),
                            entry.getAccessSecret(), entry.getVerificationCode(), entry.getIdentity() });

                    logger.info("Updated Authentication Results for " + entry.getChannelName());
                } catch (DataAccessException e2) {
                    logger.error("Exception while updating authentication results for " + entry.getChannelName()
                            + " " + e2.getMessage());
                }
            }
        }
    }
}

From source file:com.sr.model.dao.IMahasiswaDAOImpl.java

@Override
public boolean insertBiodata(Mahasiswa mhs, AkademikSR aka, FileItem foto, List<Prestasi> prestasi) {
    try {//from   w  w w  .  j a v a  2  s  .c  om
        LobHandler lobHandler = new DefaultLobHandler();
        getJdbcTemplate().update(INSERT_BIODATA, new Object[] { mhs.getNamaMhs(), mhs.getTempat_lahir(),
                mhs.getTanggal_lahir(), mhs.getAgama(), mhs.getKelamin(), mhs.getAlamat_asal(),
                mhs.getKab_kota_asal(), mhs.getProv_asal(), mhs.getNo_hp_mhs(), mhs.getNama_ayah(),
                mhs.getNama_ibu(), mhs.getPendidikan_ayah(), mhs.getPendidikan_ibu(), mhs.getPekerjaan_ayah(),
                mhs.getPekerjaan_ibu(), mhs.getPendapatan_ortu(), mhs.getNo_tel_ortu(), mhs.getNo_hp_ortu(),
                mhs.getAlamat_keluarga(), mhs.getNo_tel_keluarga(), mhs.getNo_hp_keluarga(),
                new SqlLobValue(foto.getInputStream(), (int) foto.getSize(), lobHandler), mhs.getNim() },
                new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.NUMERIC, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.VARCHAR, Types.BLOB, Types.VARCHAR });
        getJdbcTemplate().update(INSERT_AKADEMIK,
                new Object[] { aka.getProdi(), aka.getIpk_masuk(), aka.getSemester(), aka.getRapor_smu(),
                        aka.getJurusan(), aka.getFakultas(), aka.getNim() },
                new int[] { Types.VARCHAR, Types.DECIMAL, Types.NUMERIC, Types.DECIMAL, Types.VARCHAR,
                        Types.VARCHAR, Types.VARCHAR });
        for (Prestasi pres : prestasi) {
            getJdbcTemplate().update(INSERT_PRESTASI, new Object[] { pres.getNo_sertifikat(), pres.getNim(),
                    pres.getNama_prestasi(), pres.getJenis_prestasi() });
        }
        return true;
    } catch (DataAccessException da) {
        System.out.println("DataAccessException" + da.getMessage());
    } catch (FileNotFoundException ex) {
        System.out.println("FileNotFoundException " + ex.getMessage());
    } catch (IOException ex) {
        System.out.println(ex.getMessage());
    }
    return false;
}

From source file:net.jkratz.igdb.controller.advice.ErrorController.java

@RequestMapping(produces = "application/json")
@ExceptionHandler(DataAccessException.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public @ResponseBody Map<String, Object> handleDataAccessException(DataAccessException ex) throws IOException {
    logger.error("Database Error", ex);
    Map<String, Object> map = Maps.newHashMap();
    map.put("error", "Data Error");
    map.put("message", ex.getMessage());
    if (ex.getRootCause() != null) {
        map.put("cause", ex.getRootCause().getMessage());
    }/*from www . j av  a2s.  c o  m*/
    return map;
}