Example usage for java.sql SQLException getMessage

List of usage examples for java.sql SQLException getMessage

Introduction

In this page you can find the example usage for java.sql SQLException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:cz.incad.Kramerius.security.rightscommands.post.Delete.java

@Override
public void doCommand() {
    try {//ww  w .j a  v  a 2 s . co m

        HttpServletRequest req = this.requestProvider.get();
        //Right right = RightsServlet.createRightFromPost(req, rightsManager, userManager, criteriumWrapperFactory);
        Map values = new HashMap();
        Enumeration parameterNames = req.getParameterNames();

        while (parameterNames.hasMoreElements()) {
            String key = (String) parameterNames.nextElement();
            String value = req.getParameter(key);
            SimpleJSONObjects simpleJSONObjects = new SimpleJSONObjects();
            simpleJSONObjects.createMap(key, values, value);
        }

        List rightsToDelete = (List) values.get("deletedrights");

        for (int i = 0; i < rightsToDelete.size(); i++) {
            String id = rightsToDelete.get(i).toString();
            deleteRight(Integer.parseInt(id));

        }

    } catch (SQLException e) {
        try {
            this.responseProvider.get().sendError(HttpServletResponse.SC_FORBIDDEN);
        } catch (IOException e1) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
    }
}

From source file:edu.lternet.pasta.dml.database.SimpleDatabaseLoader.java

/**
 * Constructor of this class. Sets up the necessary components for loading data
 * //from  ww w .j a va  2s .c  o m
 * @param dbAdapter
 *            Database adapter name
 * @param entity
 *            Metadata information associated with the loader
 * @param dataReader
 *            the data for the loader            
 */
public SimpleDatabaseLoader(String databaseAdapterName, Entity entity, TextDataReader dataReader) {

    //the description
    this.entity = entity;

    //the data
    this.dataReader = dataReader;

    /* Initialize the databaseAdapter and tableMonitor fields */
    this.databaseAdapter = DataManager.getDatabaseAdapterObject(databaseAdapterName);

    try {
        tableMonitor = new TableMonitor(databaseAdapter);
    } catch (SQLException e) {
        log.error("problem setting table monitor: " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:gov.nih.nci.cacisweb.dao.virtuoso.VirtuosoCDWUserPermissionDAO.java

@Override
public List<CdwPermissionModel> searchUserPermissions(CdwUserModel cdwUserModel) throws DAOException {
    log.debug("searchUserPermissions(CDWUserModel cdwUserModel) - start");
    ArrayList<CdwPermissionModel> userPermissionList = new ArrayList<CdwPermissionModel>();
    StringBuffer query = new StringBuffer();
    query.append("SELECT A.RGG_IRI from DB.DBA.RDF_GRAPH_GROUP A, DB.DBA.RDF_GRAPH_USER B, "
            + "DB.DBA.SYS_USERS C WHERE A.RGG_IID = B.RGU_GRAPH_IID and B.RGU_USER_ID = C.U_ID and "
            + "C.U_NAME = ?");
    try {//from w w w .  j  a  v a  2 s. co  m
        pstmt = new LoggableStatement(cacisConnection, query.toString());
        pstmt.setString(1, cdwUserModel.getUsername());
        log.info("SQL searchUserPermissions(CDWUserModel cdwUserModel): " + pstmt.toString());
        rs = pstmt.executeQuery();

        while (rs.next()) {
            String graphGroupRGGIRI = rs.getString(1);
            String[] studySitePatientArray = StringUtils.split(graphGroupRGGIRI, "/");
            CdwPermissionModel cdwPermissionModel = new CdwPermissionModel();
            cdwPermissionModel.setGraphGroupRGGIRI(graphGroupRGGIRI);
            if (studySitePatientArray.length >= 3) {
                cdwPermissionModel.setStudyID(studySitePatientArray[2]);
                if (studySitePatientArray.length >= 4) {
                    cdwPermissionModel.setSiteID(studySitePatientArray[3]);
                    if (studySitePatientArray.length >= 5) {
                        cdwPermissionModel.setPatientID(studySitePatientArray[4]);
                    }
                }
            }
            userPermissionList.add(cdwPermissionModel);
        }
    } catch (SQLException sqle) {
        log.error(sqle.getMessage(), sqle);
        throw new DAOException(sqle.getMessage());
    }
    log.debug("searchUserPermissions(CDWUserModel cdwUserModel) - end");
    return userPermissionList;
}

From source file:com.dangdang.ddframe.job.event.rdb.JobRdbEventStorage.java

boolean addJobExecutionEvent(final JobExecutionEvent jobExecutionEvent) {
    boolean result = false;
    if (null == jobExecutionEvent.getCompleteTime()) {
        String sql = "INSERT INTO `job_execution_log` (`id`, `job_name`, `hostname`, `sharding_items`, `execution_source`, `is_success`, `start_time`) "
                + "VALUES (?, ?, ?, ?, ?, ?, ?);";
        try (Connection conn = dataSource.getConnection();
                PreparedStatement preparedStatement = conn.prepareStatement(sql)) {
            preparedStatement.setString(1, jobExecutionEvent.getId());
            preparedStatement.setString(2, jobExecutionEvent.getJobName());
            preparedStatement.setString(3, jobExecutionEvent.getHostname());
            preparedStatement.setString(4, jobExecutionEvent.getShardingItems().toString());
            preparedStatement.setString(5, jobExecutionEvent.getSource().toString());
            preparedStatement.setBoolean(6, jobExecutionEvent.isSuccess());
            preparedStatement.setTimestamp(7, new Timestamp(jobExecutionEvent.getStartTime().getTime()));
            preparedStatement.execute();
            result = true;//  ww w  .j av a  2  s  .  c o m
        } catch (final SQLException ex) {
            // TODO ,???
            log.error(ex.getMessage());
        }
    } else {
        if (jobExecutionEvent.isSuccess()) {
            String sql = "UPDATE `job_execution_log` SET `is_success` = ?, `complete_time` = ? WHERE id = ?";
            try (Connection conn = dataSource.getConnection();
                    PreparedStatement preparedStatement = conn.prepareStatement(sql)) {
                preparedStatement.setBoolean(1, jobExecutionEvent.isSuccess());
                preparedStatement.setTimestamp(2, new Timestamp(jobExecutionEvent.getCompleteTime().getTime()));
                preparedStatement.setString(3, jobExecutionEvent.getId());
                preparedStatement.execute();
                result = true;
            } catch (final SQLException ex) {
                // TODO ,???
                log.error(ex.getMessage());
            }
        } else {
            String sql = "UPDATE `job_execution_log` SET `is_success` = ?, `failure_cause` = ? WHERE id = ?";
            try (Connection conn = dataSource.getConnection();
                    PreparedStatement preparedStatement = conn.prepareStatement(sql)) {
                preparedStatement.setBoolean(1, jobExecutionEvent.isSuccess());
                preparedStatement.setString(2, getFailureCause(jobExecutionEvent.getFailureCause()));
                preparedStatement.setString(3, jobExecutionEvent.getId());
                preparedStatement.execute();
                result = true;
            } catch (final SQLException ex) {
                // TODO ,???
                log.error(ex.getMessage());
            }
        }
    }
    return result;
}

From source file:Database.Handler.java

public List<T> searchQuery(String sql, Class outputClass) {
    List<T> list;//from   ww  w  .ja  v  a  2 s  .co m
    try {
        Connection c = DriverManager.getConnection(DbConfig.connectionString, DbConfig.dbUserName,
                DbConfig.dbPassword);
        Statement s = c.createStatement();
        ResultSet rs = s.executeQuery(sql);
        list = mapRersultSetToObject(rs, outputClass);
        s.close();
        c.close();
        return list;
    } catch (SQLException e) {
        System.out.println("Handler searchQuery error:" + e.getMessage());
        return null;
    }
}

From source file:edu.mayo.cts2.uriresolver.dao.UriDAOJdbc.java

@Override
public int checkDataSource(DataSource ds) {
    Connection con = null;// w  w w. jav a 2s .  com
    int code = 0;
    try {
        con = ds.getConnection();
    } catch (SQLException e) {
        String msg = e.getMessage();
        logger.error("Error connecting to data source: " + msg + "\n");
        return code;
    } finally {
        if (con != null) {
            try {
                con.close();
            } catch (SQLException e) {
                logger.error("Error while closing connection to data source: " + e.getMessage());
            }
        }
    }
    return code;
}

From source file:com.sap.dirigible.repository.ext.db.DBUtils.java

public void closeConnection(Connection connection) {
    logger.debug("entering closeConnection"); //$NON-NLS-1$
    if (connection != null) {
        try {/* w w  w  .  j a v  a 2 s  .  co m*/
            connection.close();
        } catch (SQLException e) {
            logger.error(e.getMessage());
        }
    }
    logger.debug("exiting closeConnection"); //$NON-NLS-1$
}

From source file:com.sap.dirigible.repository.ext.db.DBUtils.java

public void closeStatement(Statement statement) {
    logger.debug("entering closeStatement"); //$NON-NLS-1$
    if (statement != null) {
        try {//from w  w w  . j a va  2 s .  c  o m
            statement.close();
        } catch (SQLException e) {
            logger.error(e.getMessage());
        }
    }
    logger.debug("exiting closeStatement"); //$NON-NLS-1$
}

From source file:it.gulch.linuxday.android.fragments.TrackScheduleListFragment.java

private void setupServices(Activity activity) {
    try {/*from w  w w . j a  v  a 2s  . co  m*/
        eventManager = DatabaseManagerFactory.getEventManager(activity);
    } catch (SQLException e) {
        Log.e(TAG, e.getMessage(), e);
    }
}

From source file:OCCIConnectionServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Oracle Cached Connection " + "Implementation Test Servlet</title>");
    out.println("</head>");
    out.println("<body>");

    // let's turn on verbose output
    OCCIConnection.setVerbose(true);//from w  w w  .  j  av a 2 s  . c om
    // now let's get a cached connection
    Connection connection = OCCIConnection.checkOut();

    Statement statement = null;
    ResultSet resultSet = null;
    String userName = null;
    try {
        // test the connection
        statement = connection.createStatement();
        resultSet = statement.executeQuery("select initcap(user) from sys.dual");
        if (resultSet.next())
            userName = resultSet.getString(1);
    } catch (SQLException e) {
        out.println("DedicatedConnection.doGet() SQLException: " + e.getMessage() + "<p>");
    } finally {
        if (resultSet != null)
            try {
                resultSet.close();
            } catch (SQLException ignore) {
            }
        if (statement != null)
            try {
                statement.close();
            } catch (SQLException ignore) {
            }
    }

    // let's add a little delay so we can force
    // multiple connections in the connection cache
    for (int o = 0; o < 3; o++) {
        for (int i = 0; i < 2147483647; i++) {
        }
    }

    // let's return the conection
    OCCIConnection.checkIn(connection);

    out.println("Hello " + userName + "!<p>");
    out.println("You're using an Oracle Cached " + "Connection Implementation connection!<p>");
    out.println("</body>");
    out.println("</html>");
}