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:org.dcache.chimera.DirectoryStreamImpl.java

public void close() throws IOException {
    try {/*from w  w w. j  a  v a  2 s.c o m*/
        JdbcUtils.closeResultSet(_resultSet);
        JdbcUtils.closeStatement(_statement);
        DataSourceUtils.releaseConnection(_connection, _jdbc.getDataSource());
    } catch (DataAccessException e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:org.xaloon.wicket.security.spring.external.ExternalAuthenticationProvider.java

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    if (StringUtils.isEmpty(authentication.getName())) {
        throw new IllegalArgumentException("Authentication username is not provided!");
    }//from  w  w w  . jav a  2 s  .c o  m
    UserDetails loadedUser = null;
    AuthenticationToken initialToken = null;
    if (authentication instanceof SpringAuthenticationToken) {
        initialToken = ((SpringAuthenticationToken) authentication).getToken();
    }
    try {
        loadedUser = userDetailsService.loadUserByUsername(authentication.getName());
    } catch (DataAccessException repositoryProblem) {
        throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
    } catch (UsernameNotFoundException e) {
    }

    if (loadedUser == null) {
        return createExternalAuthenticationToken(authentication, initialToken);
    } else {
        return createDefaultAuthenticationToken(authentication, loadedUser);
    }
}

From source file:com.github.carlomicieli.rest.resources.ScalesResource.java

@GET
@Path("/{scaleId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getScale(@PathParam("scaleId") long scaleId) {
    log.info("GET /scales/{}", scaleId);

    try {/*from   w  w w.  java2  s .c  o m*/
        final ScaleRepresentation scaleRep = new ScaleRepresentation(scaleService.getScale(scaleId));
        return Response.ok(scaleRep).tag(scaleRep.tag()).cacheControl(getCacheControl()).build();
    } catch (DataAccessException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:com.github.carlomicieli.rest.resources.ScalesResource.java

/**
 * Return the list of all brands./*from   w w  w.j av a  2s .c o m*/
 * <p>
 * <code>GET /brands</code>
 * </p>
 * 
 * @return the list of brands.
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getScales() {
    log.info("GET /scales");

    try {
        final ScaleRepresentation[] scales = createArray(scaleService.getAllScales());

        return Response.ok(scales).cacheControl(getCacheControl()).build();
    } catch (DataAccessException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}

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

/**
 * Creates the IsbPayloadBean.//from  w  ww  .j av  a2 s  .c o  m
 *
 * @param isbPayload the isb payload
 *
 * @return true, if successful
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final boolean create(final IsbPayloadBean isbPayload) throws WhichDoctorDaoException {
    boolean success = false;

    try {
        final int createCount = this.getIsbJdbcTemplate().update(this.getSQL().getValue("isbpayload/create"),
                new Object[] { isbPayload.getIsbMessageId(), isbPayload.getXmlPayload() });

        if (createCount > 0) {
            success = true;
        }
    } catch (DataAccessException de) {
        dataLogger.error("Error creating ISB payload: " + de.getMessage());
    }
    return success;
}

From source file:com.persistent.cloudninja.dao.impl.ManageUsersDaoImpl.java

@SuppressWarnings("unchecked")
@Override/*  w ww.  j  av  a  2  s .com*/
public Member getMemberFromDbUsingGUID(String tenantId, String GUID) {
    LOGGER.info("ManageUsersDaoImpl: getMemberFromDbUsingGUID Start");
    Member member = null;
    List<Member> memberList = null;

    try {
        memberList = hibernateTemplate.find("from Member where TenantId=? AND LiveGUID=?", tenantId, GUID);
        if (null != memberList && memberList.size() > 0) {
            member = memberList.get(0);
        }
    } catch (DataAccessException de) {
        LOGGER.error(de.getMessage(), de);
        member = null;
    }
    LOGGER.info("ManageUsersDaoImpl: getMemberFromDbUsingGUID End");
    return member;
}

From source file:com.persistent.cloudninja.dao.impl.ManageUsersDaoImpl.java

/**
 * Get the member from database/*w w  w  .ja  v  a  2s  . c o  m*/
 * @param tenentId
 * @param memberId
 * @return Member object if found else returns null
 */
@SuppressWarnings("unchecked")
@Override
public Member getMemberFromDb(String tenantId, String memberId) throws SystemException {
    LOGGER.info("ManageUsersDaoImpl: getMemberFromDb Start");
    Member member = null;
    List<Member> memberList = null;

    try {
        memberList = hibernateTemplate.find("from Member where TenantId=? AND MemberId=?", tenantId, memberId);
        if (null != memberList && memberList.size() > 0) {
            member = memberList.get(0);
        }
    } catch (DataAccessException de) {
        LOGGER.error(de.getMessage(), de);
        member = null;
    }
    LOGGER.info("ManageUsersDaoImpl: getMemberFromDb End");
    return member;
}

From source file:org.sakaiproject.tool.tasklist.impl.TaskListManagerJdbcImpl.java

public void init() {
    // get the autoDdl value
    autoDdl = org.sakaiproject.component.cover.ServerConfigurationService.getInstance().getBoolean("auto.ddl",
            true);/* w  w w.  j  a va 2s . co m*/

    if (autoDdl) {
        /*
         * this will create our table, this is fragile but functional,
         * it will not be able to recreate the table if it changes,
         * if you use something like this in production, it is likely that
         * Glenn will have you killed - AZ
         */
        try {
            SqlService sqlService = org.sakaiproject.db.cover.SqlService.getInstance();
            if (sqlService.getVendor().equals("hsqldb")) {
                getJdbcTemplate().execute(TASK_CREATE_TABLE_HSQLDB);
                log.info("Created tasklist table in hsqldb");
            } else if (sqlService.getVendor().equals("mysql")) {
                getJdbcTemplate().execute(TASK_CREATE_TABLE_MYSQL);
                log.info("Created tasklist table in mysql");
            } else if (sqlService.getVendor().equals("oracle")) {
                getJdbcTemplate().execute(TASK_CREATE_TABLE_ORACLE);
                getJdbcTemplate().execute(TASK_CREATE_SEQ_ORACLE);
                getJdbcTemplate().execute(TASK_CREATE_TRIGGER_ORACLE);
                log.info("Created tasklist table in oracle");
            } else {
                log.error("Unknown database type, cannot create task table");
            }
        } catch (DataAccessException e) {
            log.info("Tasklist JDBC exception: " + e.getMessage());
        }
    } else {
        log.warn("AUTO DDL IS OFF, tasklist table not created:");
    }
}

From source file:com.github.carlomicieli.rest.resources.RollingStocksResource.java

@GET
@Path("/{id}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response get(@PathParam("id") long id) {
    log.info("GET /rollingstocks/{}", id);

    try {/* w w w  .  j  a v  a 2 s  .com*/
        final RollingStockRepresentation rs = new RollingStockRepresentation(rsService.getRollingStock(id));
        return Response.ok(rs).tag(rs.tag()).cacheControl(getCacheControl()).build();
    } catch (DataAccessException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}

From source file:com.github.carlomicieli.rest.resources.RollingStocksResource.java

/**
 * Gets the list of rolling stocks representation.
 * @return the list of rolling stocks.//ww w. j a  v  a  2s  .  c  o  m
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRollingStocks() {
    log.info("GET /rollingstocks");

    try {
        final RollingStockRepresentation[] rollingStocks = createArray(rsService.getAllRollingStocks());

        return Response.ok(rollingStocks).cacheControl(getCacheControl()).build();
    } catch (DataAccessException ex) {
        log.error(ex.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
}