Example usage for org.springframework.dao DataAccessException printStackTrace

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

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

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;//www .ja  va  2s. c o  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:net.navasoft.madcoin.backend.services.security.ProviderDataAccess.java

/**
 * Load user by username./*w w w. j a  v  a 2 s.  c o  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.siacra.beans.HorarioBean.java

/**
 * Locked Horario/*w ww .  j  a v  a 2  s .  c  om*/
 *
 */
public void lockedHorario() {

    try {
        Horario horario = getHorarioService().getHorarioById(getIdHorario());
        String horarioBloqueado = horario.getDia1() + ": " + horario.getHinicio1() + " - " + horario.getHfin1()
                + " a " + horario.getDia2() + ": " + horario.getHinicio2() + " - " + horario.getHfin2();
        horario.setHoEstado(false);
        getHorarioService().updateHorario(horario);
        addMessage("El horario " + horarioBloqueado + " fue inhabilitado correctamente");

    } catch (DataAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.siacra.beans.HorarioBean.java

/**
 * Unlocked Horario/*from   w  ww .  java  2  s.c  om*/
 *
 */
public void unlockedHorario() {

    try {
        Horario horario = getHorarioService().getHorarioById(getIdHorario());
        String horarioBloqueado = horario.getDia1() + ": " + horario.getHinicio1() + " - " + horario.getHfin1()
                + " a " + horario.getDia2() + ": " + horario.getHinicio2() + " - " + horario.getHfin2();
        horario.setHoEstado(true);
        getHorarioService().updateHorario(horario);
        addMessage("El horario " + horarioBloqueado + " fue habilitado correctamente");

    } catch (DataAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.siacra.beans.HorarioBean.java

public void updateHorario() {
    try {//from  www  . ja v a  2s  . c o m

        Horario horario = getHorarioService().getHorarioById(getIdHorario());
        horario.setHinicio1(getHinicio1());
        horario.setHfin1(getHfin1());
        horario.setDia1(getDia1());
        horario.setHinicio2(getHinicio2());
        horario.setHfin2(getHfin2());
        horario.setDia2(getDia2());
        horario.setEscuela(escuelaService.getEscuelaById(getIdescuela()));
        getHorarioService().updateHorario(horario);
        addMessage("El Horario fue actualizado correctamente");

    } catch (DataAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.siacra.beans.HorarioBean.java

public void deleteHorario() {
    try {//  w ww .j  av a 2 s  .  c  o m
        Horario horario = getHorarioService().getHorarioById(getIdHorario());

        if (horario.getGrupo() == null) {
            getHorarioService().deleteHorario(horario);
            addMessage("El Horario fue eliminado correctamente");
        } else {
            horario.setHoEstado(false);
            getHorarioService().updateHorario(horario);
            addMessage("El Horario fue dado de baja correctamente");
        }

    } catch (DataAccessException e) {
        e.printStackTrace();
        addMessage("El Horario no puede ser eliminado debido a que tiene registros relacionados");
    }
}

From source file:com.siacra.beans.HorarioBean.java

public void addHorario() {

    try {/*from   ww w  .j  av a 2s .c  o m*/
        Horario horario = new Horario();
        horario.setHinicio1(hinicio1);
        horario.setHfin1(hfin1);
        horario.setDia1(dia1);
        horario.setHinicio2(hinicio2);
        horario.setHfin2(hfin2);
        horario.setDia2(dia2);
        horario.setEscuela(escuelaService.getEscuelaById(idescuela));
        horario.setHoEstado(true);

        if (getHorarioService().getExistHorario(getHinicio1(), getHfin1(), getDia1(), getHinicio2(), getHfin2(),
                getDia2(), getIdescuela())) {
            //addMessage("El horario con periodo :" + formato.format(getHinicio()) +" - "+formato.format(getHfin())+ " para el dia  : " + getDia()+ " ya existe");
            addMessage("El horario ya existe, por favor ingrese un horario no registrado");
        } else {
            getHorarioService().addHorario(horario);
            addMessage("El horario fue creado exitosamente");
            reset();
            setInsert(false);
            //                addMessage("El horario con periodo :" + formato.format(getHinicio())+ " - "+formato.format(getHfin()) + " para el dia : " + getDia()+ " fue creado exitosamente");
        }
    } catch (DataAccessException e) {
        e.printStackTrace();
    }
}

From source file:info.smartkit.hairy_batman.query.SogouSearchQuery.java

public void parseWxOpenId() {
    Document doc;//  w w w . j a  va2 s.  c o m
    try {

        // need http protocol
        // doc = Jsoup.connect(GlobalConsts.SOGOU_SEARCH_URL_BASE+ wxFoo.getSubscribeId()).get();
        doc = Jsoup.connect("http://weixin.sogou.com/weixin?type=1&query=" + wxFoo.getSubscribeId()
                + "&fr=sgsearch&ie=utf8&_ast=1423915648&_asf=null&w=01019900&cid=null&sut=19381").get();

        LOG.debug("openID html INFO:" + doc.html());

        // get page title
        String title = doc.title();
        LOG.debug("title : " + title);
        // get all "?:" value of html <span>
        //Elements openIdLink = doc.select(GlobalConsts.SOGOU_SEARCH_WX_OPEN_ID_HTML_ELEMENTS).select(GlobalConsts.SOGOU_SEARCH_WX_OPEN_ID_HTML_ELE_IDENTITY);

        Elements openIdLink = doc.getElementsByClass("wx-rb");
        Element a = null;
        String openIdLinkHref = "";
        if (openIdLink != null && openIdLink.size() > 0) {
            Iterator<Element> itea = openIdLink.iterator();
            while (itea.hasNext()) {
                a = itea.next();
                LOG.debug("openID html INFO:" + a.html());
                if (a.getElementsByTag("em").html().indexOf(wxFoo.getSubscribeId()) != -1) {
                    break;
                }
            }
        }
        if (a != null) {
            openIdLinkHref = a.attr("href");
        }
        LOG.debug("openIdLinkHref:" + openIdLinkHref);
        // FIXME:????
        if (this.wxFoo.getOpenId() == null && openIdLinkHref.length() > 0) {

            this.wxFoo.setOpenId(openIdLinkHref.split(GlobalConsts.SOGOU_SEARCH_WX_OPEN_ID_KEYWORDS)[1]);
            LOG.info("saved wxOpenId value: " + this.wxFoo.getOpenId());
            GlobalVariables.wxFooListWithOpenId.add(this.wxFoo);
            // File reporting
            new FileReporter(GlobalConsts.REPORT_FILE_OUTPUT_OPENID, GlobalVariables.wxFooListWithOpenId,
                    FileReporter.REPORTER_TYPE.R_T_OPENID, FileReporter.REPORTER_FILE_TYPE.EXCEL).write();
            // Then,OpenID JSON site parse
            if (this.wxFoo.getOpenId() != null) {
                // Save openId to DB.
                try {
                    GlobalVariables.jdbcTempate.update("insert into " + GlobalConsts.QUERY_TABLE_NAME_BASIC
                            + "(id,store,agency,unit,subscribeId,onSubscribe,code,openId) values(?,?,?,?,?,?,?,?)",
                            new Object[] { this.wxFoo.getId(), this.wxFoo.getStore(), this.wxFoo.getAgency(),
                                    this.wxFoo.getUnit(), this.wxFoo.getSubscribeId(),
                                    this.wxFoo.getOnSubscribe(), this.wxFoo.getCode(), this.wxFoo.getOpenId() },
                            new int[] { java.sql.Types.INTEGER, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR,
                                    java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR,
                                    java.sql.Types.VARCHAR, java.sql.Types.VARCHAR });
                    this.parseSogouJsonSite(this.wxFoo.getOpenId());
                } catch (DataAccessException e) {
                    e.printStackTrace();
                }
            } else {
                LOG.warn("SogouSearchQuery getOpenId Failure! site info:" + wxFoo.getCode());
                // TODO write those info to File or DB for collect which
                // agency not open weixin service
                // Save openId to DB.
                try {
                    GlobalVariables.jdbcTempate.update("insert into " + GlobalConsts.QUERY_TABLE_NAME_BASIC
                            + "(id,store,agency,unit,subscribeId,onSubscribe,code,openId) values(?,?,?,?,?,?,?,?)",
                            new Object[] { this.wxFoo.getId(), this.wxFoo.getStore(), this.wxFoo.getAgency(),
                                    this.wxFoo.getUnit(), this.wxFoo.getSubscribeId(),
                                    this.wxFoo.getOnSubscribe(), this.wxFoo.getCode(), "" },
                            new int[] { java.sql.Types.INTEGER, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR,
                                    java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR,
                                    java.sql.Types.VARCHAR, java.sql.Types.VARCHAR });
                    LOG.warn("Can not get subsriber info: " + this.wxFoo.getCode());

                    this.parseSogouJsonSite(this.wxFoo.getOpenId());
                } catch (DataAccessException e) {
                    e.printStackTrace();
                }
            }
        }

    } catch (IOException e) {
        // e.printStackTrace();
        LOG.error(e.toString());
    }
}

From source file:pe.gob.mef.gescon.hibernate.impl.ContenidoDaoImpl.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;/*w w w . j  a va2  s  .c  om*/
    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.vrespuesta 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 AND a.NTPOCONOCIMIENTOID = ").append(ntipoconocimientoid)
                    .append(" "); // 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:pe.gob.mef.gescon.hibernate.impl.ConocimientoDaoImpl.java

@Override
public List<HashMap> getConcimientosByVinculoBaseLegalId(final BigDecimal id) {
    final StringBuilder sql = new StringBuilder();
    Object object = null;//from   w  w  w  . j  a  v a  2  s.c  o m
    try {
        sql.append("SELECT t.nconocimientoid AS ID ");
        sql.append("FROM tconocimiento t ");
        sql.append("INNER JOIN tvinculo x ");
        sql.append("ON x.nconocimientoid = t.nconocimientoid ");
        sql.append("AND x.nconocimientovinc = :IDCONOCIMIENTO ");
        sql.append("AND x.ntipoconocimientovinc = :TIPO ");
        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);
                query.setParameter("IDCONOCIMIENTO", id);
                query.setParameter("TIPO", BigDecimal.ONE);
                return query.list();
            }
        });
    } catch (DataAccessException e) {
        e.getMessage();
        e.printStackTrace();
    }
    return (List<HashMap>) object;
}