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:com.idiro.utils.db.mysql.MySqlUtils.java

public boolean exportTable(JdbcConnection conn, String tableName, File out, Map<String, String> features,
        char delimiter, boolean header, Collection<String> quotes) {

    String[] options = new String[1];
    try {//  w w  w .j ava 2  s. com
        options[0] = File.createTempFile("idiro", tableName).getAbsolutePath();
    } catch (IOException e1) {
        logger.error("Fail to create temporary local file");
        logger.error(e1.getMessage());
        return false;
    }

    try {
        conn.exportTableToFile(tableName, features, options);
    } catch (SQLException e) {
        logger.debug(e.getMessage());
        return false;
    }

    if (out.exists()) {
        out.delete();
    }
    return changeFormatAfterExport(new File(options[0]), out, delimiter, features.keySet(), quotes);

}

From source file:be.ugent.tiwi.sleroux.newsrec.stormNewsFetch.dao.mysqlImpl.JDBCRatingsDao.java

/**
 *
 * @param userid//from   w w  w  .j av  a  2s .co m
 * @param term
 * @param rating
 * @throws RatingsDaoException
 */
@Override
public void giveRating(long userid, String term, double rating) throws RatingsDaoException {
    try {
        logger.debug("set rating for user: " + userid + " and term: " + term + " to: " + rating);
        insertUpdateRatingStatement.setLong(1, userid);
        insertUpdateRatingStatement.setString(2, term);
        insertUpdateRatingStatement.setDouble(3, rating);
        insertUpdateRatingStatement.setDouble(4, rating);

        int result = insertUpdateRatingStatement.executeUpdate();
        logger.debug("return value insert/update: " + result);
    } catch (SQLException ex) {
        logger.error("Error updating rating", ex);
        throw new RatingsDaoException("Error updating rating: " + ex.getMessage(), ex);
    }
}

From source file:MyStatsPanel.java

void getDatabaseInfo() {
    try {/*from   w  w  w .  jav  a2  s  .com*/
        String SQL_Query = " Select count(*)" + " From Visitation_Detail v" + " Where v.time_out is null ";

        myResultSet = statement.executeQuery(SQL_Query);
        myResultSet.first();
        totalGuestsIn = myResultSet.getInt(1) + "";
        myResultSet.close();

        SQL_Query = " Select count(*)" + " From Visitation_Detail v" + " Where v.visitation_date = curdate() ";

        myResultSet = statement.executeQuery(SQL_Query);
        myResultSet.first();
        todaysCheckIns = myResultSet.getInt(1) + "";
        myResultSet.close();

        SQL_Query = " Select count(*)" + " From Visitation_Detail v"
                + " Where v.visitation_date = curdate() and v.time_out is not null ";

        myResultSet = statement.executeQuery(SQL_Query);
        myResultSet.first();
        todaysCheckOuts = myResultSet.getInt(1) + "";
        myResultSet.close();

        SQL_Query = " Select count(*)" + " From Visitation_Detail v"
                + " Where v.time_out is null and v.overnight_status = 'Yes' ";

        myResultSet = statement.executeQuery(SQL_Query);
        myResultSet.first();
        totalOvernights = myResultSet.getInt(1) + "";
        myResultSet.close();
    } catch (SQLException sqlException) {
        JOptionPane.showMessageDialog(this, sqlException.getMessage());
    } catch (Exception exception) {
        JOptionPane.showMessageDialog(this, exception.getMessage());
    }
}

From source file:be.ugent.tiwi.sleroux.newsrec.stormNewsFetch.dao.mysqlImpl.JDBCViewsDao.java

/**
 *
 * @param userid/*ww  w  .j  a  va 2  s .com*/
 * @param docnr
 * @param itemid
 * @throws ViewsDaoException
 */
@Override
public void see(long userid, int docnr, long itemid) throws ViewsDaoException {
    try {
        logger.debug(userid + " has seen " + docnr);
        insertViewsStatement.setLong(1, userid);
        insertViewsStatement.setInt(2, docnr);
        insertViewsStatement.setLong(3, itemid);

        int result = insertViewsStatement.executeUpdate();
        logger.debug("return value insert/update: " + result);
    } catch (SQLException ex) {
        logger.error("Error updating rating", ex);
        throw new ViewsDaoException("Error inserting view: " + ex.getMessage(), ex);
    }
}

From source file:com.nextep.designer.data.ui.editors.DataSetComparisonEditor.java

@Override
public void dispose() {
    if (connection != null) {
        try {//from   w  w  w  . j a v a2 s.c  o  m
            connection.close();
        } catch (SQLException e) {
            LOGGER.warn(DataUiMessages.getString("editor.dataset.comparison.closeConnectionFailed") //$NON-NLS-1$
                    + e.getMessage(), e);
        }
    }
    super.dispose();
}

From source file:pl.edu.agh.iosr.lsf.RootController.java

@RequestMapping(value = "/test/{name}", method = RequestMethod.GET)
public String runTest(@PathVariable(value = "name") String name) {
    try {//w w w. java 2 s  . co m
        return dh.benhmarkStatement(name) + "";
    } catch (SQLException e) {
        return e.getMessage();
    }
}

From source file:eu.optimis.mi.monitoring_manager.test.MonitoringManagerTest.java

private boolean deleteResources(String type) {
    DBConnection dbconn = new DBConnection();
    Connection conn = dbconn.getConnection();

    String query;/*from   w w  w. ja  v  a2s .  c om*/
    if (type.equals("physical"))
        query = "Delete FROM monitoring_resource_physical where physical_resource_id like '%UnitTest%'";
    else
        query = "Delete FROM monitoring_resource_virtual where virtual_resource_id like '%UnitTest%'";
    try {
        Statement st = conn.createStatement();
        st.executeUpdate(query);

    } catch (SQLException e) {
        logger.error("SQLException:" + e.getMessage() + ":" + e.getSQLState());
        return false;
    } finally {
        try {
            conn.close();
        } catch (Exception e) {
        }
    }
    return true;
}

From source file:pl.edu.agh.iosr.lsf.RootController.java

@RequestMapping(value = "keyword", method = RequestMethod.PUT)
public String insertKeyword(@RequestParam(value = "name") String key,
        @RequestParam(value = "category") String cat) {
    try {/*from w w  w. j av  a2s  . c om*/
        return "" + dh.insertKeyword(key, cat);
    } catch (SQLException e) {
        return e.getMessage();
    }
}

From source file:pl.edu.agh.iosr.lsf.RootController.java

@RequestMapping(value = "keyword", method = RequestMethod.DELETE)
public String deleteKeyword(@RequestParam(value = "name") String key) {
    try {/*from  w  ww . j  a  va 2s. c  om*/
        dh.deleteKeyword(key);
        return "OK";
    } catch (SQLException e) {
        return e.getMessage();
    }
}

From source file:pl.edu.agh.iosr.lsf.RootController.java

@RequestMapping(value = "tag/monitored", method = RequestMethod.POST)
public String monitorTag(@RequestParam(value = "name") String tag) throws SQLException {
    try {/*from w  ww . j a v a 2  s.  co m*/
        dh.monitorTag(tag);
        return "OK";
    } catch (SQLException e) {
        return e.getMessage();
    }
}