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:TestAppletNetscape.java

public void paint(Graphics g) {
    System.out.println("paint(): querying the database");
    try {/*  w w  w .  j a  v a  2  s  .  c  om*/
        PrivilegeManager.enablePrivilege("UniversalConnect");
        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select 'Hello '||initcap(USER) result from dual");
        while (rset.next())
            g.drawString(rset.getString(1), 10, 10);
        rset.close();
        stmt.close();
    } catch (SQLException e) {
        System.err.println("paint(): SQLException: " + e.getMessage());
    }
}

From source file:cz.zcu.kiv.eegdatabase.data.dao.SimplePersonalLicenseDao.java

@Override
public byte[] getAttachmentContent(int personalLicenseId) {
    String query = "from PersonalLicense pl where pl.personalLicenseId = :id";
    PersonalLicense result = (PersonalLicense) this.getSession().createQuery(query)
            .setInteger("id", personalLicenseId).uniqueResult();
    try {//  w ww. j  a v a  2s  .co  m
        return result.getAttachmentContent().getBytes(1, (int) result.getAttachmentContent().length());
    } catch (SQLException e) {
        log.error(e.getMessage(), e);
        return new byte[0];
    }
}

From source file:eu.udig.catalog.teradata.TeradataDatabaseConnectionRunnable.java

private void checkSqlException(SQLException e) {
    if (e.getMessage().contains("[Error 3807]")) {
        result = "SYSSPATIAL.GEOMETRY_COLUMNS is either inaccessible or does not exist.  The table must both exist and be accessible to current.";
    } else if (e.getMessage().contains("[Error 8017]")) { //$NON-NLS-1$//$NON-NLS-2$
        // this is understandable the template1 database is not accessible
        // to this user/location so it is not an error
        result = "Username or password is incorrect";
    } else {// w  w  w  .j  a v a 2s .  co  m
        Activator.log("Error connecting to database dbc", e);
        result = "Unrecognized connection failure.  Check parameters and database.";
    }
}

From source file:br.com.great.dao.GruposDAO.java

public ArrayList<Grupo> getGruposJogo(int jogoConfiguracao) {
    ArrayList<Grupo> grupos = new ArrayList<Grupo>();
    PreparedStatement pstmt = null;
    ResultSet rs = null;/*from   w  w w.jav a2  s.c  o m*/
    Connection conexao = criarConexao();
    try {
        String sql = "SELECT * FROM grupos_has_confimissao "
                + " LEFT JOIN grupos on (grupos.id = grupos_has_confimissao.grupos_id) "
                + " WHERE grupos_has_confimissao.confimissao_id = " + jogoConfiguracao;
        pstmt = conexao.prepareStatement(sql);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            Grupo grupo = new Grupo();
            grupo.setId(rs.getInt("id"));
            grupo.setNome(rs.getString("nome"));
            grupos.add(grupo);
        }
    } catch (SQLException e) {
        System.out.println("Erro no getGrupoJogo: " + e.getMessage());
    } finally {
        fecharConexao(conexao, pstmt, rs);
    }
    return grupos;
}

From source file:com.ccinepal.springjdbc.controller.DefaultController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView index() {

    ModelAndView mav = new ModelAndView("index");
    try {// w  w w  .  j av  a 2 s.  c  o m

        mav.addObject("students", studentdao.getAll());

    } catch (SQLException ex) {
        System.out.println(ex.getMessage());
    }

    return mav;
}

From source file:org.dspace.versioning.DefaultItemVersionProvider.java

public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) {
    try {/*from   w  w w. j av a 2s  .c  om*/
        WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(),
                false);
        Item itemNew = workspaceItem.getItem();
        itemService.update(context, itemNew);
        return itemNew;
    } catch (SQLException e) {
        throw new RuntimeException(e.getMessage(), e);
    } catch (AuthorizeException e) {
        throw new RuntimeException(e.getMessage(), e);
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:hermes.store.jdbc.JDBCConnectionPool.java

public boolean beforeCheckin(Connection connection) {
    try {/*from  ww  w.  j a v  a2 s . c om*/
        if (connection.isClosed()) {
            return false;
        } else {
            if (!connection.getAutoCommit()) {
                connection.rollback();
            }
        }
    } catch (SQLException ex) {
        log.warn("beforeCheckin failed:" + ex.getMessage(), ex);
        return false;
    }

    return true;
}

From source file:net.refractions.udig.catalog.internal.postgis.ui.PostgisDatabaseConnectionRunnable.java

private void checkSqlException(SQLException e) {
    if (e.getMessage().contains("FATAL: no pg_hba.conf entry for host") //$NON-NLS-1$
            && e.getMessage().contains("template1")) { //$NON-NLS-1$
        // this is understandable the template1 database is not accessible to this user/location so it is not an error
    } else if (e.getMessage().contains("FATAL: role") && e.getMessage().contains("does not exist")) { //$NON-NLS-1$//$NON-NLS-2$
        // this is understandable the template1 database is not accessible to this user/location so it is not an error
        result = "Username or password is incorrect";
    } else {/*from  www.  j a  v  a  2 s .  c  o m*/
        PostgisPlugin.log("Error connecting to database template1", e);
        result = "Unrecognized connection failure.  Check parameters and database.";
    }
}

From source file:net.fender.sql.LoadBalancingDataSource.java

@Override
protected ManagedConnection getManagedConnection() throws SQLException {
    ManagedConnection managedConnection = null;
    SQLException exceptionToThrow = new SQLException();
    int tries = 0;
    while (managedConnection == null && tries <= timesToRetry) {
        DataSource dataSource = getNextDataSource();
        try {//from  w ww.ja  v a  2  s. c o  m
            Connection connection = dataSource.getConnection();
            managedConnection = new ManagedConnection(connection, this);
            if (validateConnectionOnAquire) {
                validateConnection(managedConnection);
            }
        } catch (SQLException e) {
            log.warn("connection failure " + e.getMessage());
            exceptionToThrow.setNextException(e);
            tries++;
        }
    }
    if (managedConnection == null) {
        throw exceptionToThrow;
    }
    return managedConnection;
}

From source file:at.ac.univie.isc.asio.database.MysqlSchemaService.java

@Override
public SqlSchema explore(final Id target) throws Id.NotFound {
    final SqlSchemaBuilder builder = SqlSchemaBuilder.create().noCatalog();
    try (final Connection connection = pool.getConnection()) {
        final DSLContext jooq = DSL.using(connection, SQLDialect.MYSQL);
        final org.jooq.Schema schema = findActiveSchema(jooq, target);
        builder.switchSchema(schema);//w w  w. j a v a2 s  .co m
        for (final org.jooq.Table<?> sqlTable : schema.getTables()) {
            builder.add(sqlTable);
        }
    } catch (final SQLException e) {
        throw new DataAccessResourceFailureException(e.getMessage(), e);
    }
    return builder.build();
}