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:net.duckling.falcon.api.boostrap.BootstrapDao.java

private Connection getConnection() {
    try {//  w  w w . j  a  v a2s  .c o  m
        return createDataSource.getConnection();
    } catch (SQLException e) {
        throw new WrongSQLException(e.getMessage());
    }
}

From source file:org.cloudfoundry.community.servicebroker.postgresql.service.PostgreSQLServiceInstanceBindingService.java

@Override
public void deleteServiceInstanceBinding(
        DeleteServiceInstanceBindingRequest deleteServiceInstanceBindingRequest) throws ServiceBrokerException {
    String serviceInstanceId = deleteServiceInstanceBindingRequest.getServiceInstanceId();
    String bindingId = deleteServiceInstanceBindingRequest.getBindingId();
    try {/*from w w w.j a v a 2s  . c  o m*/
        this.role.unBindRoleFromDatabase(serviceInstanceId);
    } catch (SQLException e) {
        logger.error("Error while deleting service instance binding '" + bindingId + "'", e);
        throw new ServiceBrokerException(e.getMessage());
    }
}

From source file:com.bt.aloha.testing.DbTestCase.java

public void createCollectionsTable() {
    // Create schema if does not exist
    try {//from w  ww .  ja  v a  2s.  c  om
        jdbcHelper.createCollectionsDefaultSchema(ds);
    } catch (SQLException e) {
        log.error(String.format("Error when creating database schema: %s", e.getMessage()));
    }
}

From source file:com.bt.aloha.testing.DbTestCase.java

public void createCallInfoTable() {
    // Create schema if does not exist
    try {/*from   w  w  w .  j a  v a  2  s .com*/
        jdbcHelper.createCollectionsDefaultSchema(ds);
    } catch (SQLException e) {
        log.error(String.format("Error when creating database schema: %s", e.getMessage()));
    }
}

From source file:com.bt.aloha.testing.DbTestCase.java

public void createConferenceInfoTable() {
    // Create schema if does not exist
    try {//from  www  .  j  a  v  a 2  s. co  m
        jdbcHelper.createCollectionsDefaultSchema(ds);
    } catch (SQLException e) {
        log.error(String.format("Error when creating database schema: %s", e.getMessage()));
    }
}

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

/**
 * This method provides a central location for managing commit and close operations that need to be performed on the
 * database connection at the end of the transaction. Typically intended to be called from the session bean.
 *//*from  w ww.  j  av a  2  s  .  c  om*/
public void commitAndCloseCaCISConnection() throws DAOException {
    try {
        DbUtils.commitAndClose(cacisConnection);
        DbUtils.closeQuietly(rs);
        DbUtils.closeQuietly(pstmt);
        DbUtils.closeQuietly(stmt);
    } catch (SQLException sqle) {
        log.error(sqle.getMessage());
        throw new DAOException(sqle.getMessage());
    }
}

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

/**
 * This method provides a central location for managing rollback and close operations that need to be performed on
 * the database connection if the business decision to rollback the transaction was made by the session bean's
 * business logic.//w w w  . j av  a  2  s  . c  o m
 */
public void rollbackAndCloseCaCISConnection() throws DAOException {
    try {
        DbUtils.rollback(cacisConnection);
        // DbUtils.closeQuietly(cacisConnection, stmt, rs);
        // DbUtils.closeQuietly(pstmt);
    } catch (SQLException sqle) {
        log.error(sqle.getMessage());
        throw new DAOException(sqle.getMessage());
    }

}

From source file:com.emr.utilities.DatabaseManager.java

/**
 * Constructor/*from   w w w.  j a v a2s . com*/
 * @param servername {@link String} Server name
 * @param port {@link String} Server Mysql Port
 * @param dbName {@link String} Database name
 * @param username {@link String} Mysql Username
 * @param password {@link String} Password
 */
public DatabaseManager(String servername, String port, String dbName, String username, String password) {
    this.servername = servername;
    this.port = port;
    this.url = "jdbc:mysql://" + servername + ":" + port + "/";
    this.dbName = dbName;
    this.userName = username;
    this.password = password;
    this.driver = "com.mysql.jdbc.Driver";
    try {
        Class.forName(driver).newInstance();
        conn = DriverManager.getConnection(url + dbName, userName, password);
    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
        JOptionPane.showMessageDialog(null, "SQLException: " + ex.getMessage(), "Exception!",
                JOptionPane.ERROR_MESSAGE);
    } catch (ClassNotFoundException cs) {
        System.out.println("Class not found: " + cs.getMessage());
        JOptionPane.showMessageDialog(null, "Class not found: " + cs.getMessage(), "Exception!",
                JOptionPane.ERROR_MESSAGE);
    } catch (InstantiationException | IllegalAccessException i) {
        System.out.println("Instantiation/Illegal State Error: " + i.getMessage());
        JOptionPane.showMessageDialog(null, "Instantiation/Illegal State Error: " + i.getMessage(),
                "Exception!", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:net.orpiske.ssps.sdm.main.DbInitializationHelper.java

private void initializeDbVersion() throws SQLException, DatabaseInitializationException {
    DbVersionDao dao = new DbVersionDao(databaseManager);

    try {/*from w w w  .  j  av a  2s.  com*/
        DbVersionDto dto = dao.get();

        if (dto == null) {
            logger.debug("Creating database version record");
            dto = new DbVersionDto();

            dto.setCreationDate(new Date());
            dto.setConversionDate(new Date());
            dto.setVersion("0.3.x");

            dao.insert(dto);
        }
    } catch (SQLException e) {
        String err = e.getMessage();

        if (StringUtils.containsIgnoreCase(err, "does not exist")) {
            dao.createTable();
            logger.debug("Database version table created successfully");
        } else {
            throw e;
        }
    }
}

From source file:com.bt.aloha.testing.JdbcHelper.java

protected int executeUpdate(DataSource ds, String createScript) throws SQLException {
    Connection conn = null;//from w w  w  . j  a va2 s . co  m
    Statement st = null;
    int rowCount = -1;
    try {
        conn = DataSourceUtils.getConnection(ds);
        st = conn.createStatement();
        rowCount = st.executeUpdate(createScript);
        assert rowCount > 0;
    } catch (SQLException e) {
        log.warn("Unable to execute create sctipt: " + e.getMessage());
    } finally {
        try {
            if (st != null)
                st.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            if (conn != null)
                DataSourceUtils.releaseConnection(conn, ds);
        }
    }
    return rowCount;
}