List of usage examples for java.sql SQLException getMessage
public String getMessage()
From source file:com.jfinal.plugin.activerecord.Config.java
/** * Close ResultSet?Statement?Connection/*from ww w . j a v a2 s .c o m*/ * ThreadLocal support declare transaction. */ public final void close(ResultSet rs, Statement st, Connection conn) { if (rs != null) { try { rs.close(); } catch (SQLException e) { LogKit.error(e.getMessage(), e); } } if (st != null) { try { st.close(); } catch (SQLException e) { LogKit.error(e.getMessage(), e); } } if (threadLocal.get() == null) { // in transaction if conn in threadlocal if (conn != null) { try { conn.close(); } catch (SQLException e) { throw new ActiveRecordException(e); } } } }
From source file:com.clustercontrol.sql.util.AccessDB.java
/** * DB??/*from w ww . jav a 2 s. c om*/ * */ public void terminate() { try { if (m_statement != null) m_statement.close(); } catch (SQLException e) { m_log.info("terminate() database closing failure : url = " + m_url + ", " + e.getClass().getSimpleName() + ", " + e.getMessage()); } try { if (m_connection != null) m_connection.close(); } catch (SQLException e) { m_log.info("terminate() database closing failure : url = " + m_url + ", " + e.getClass().getSimpleName() + ", " + e.getMessage()); } }
From source file:com.flexive.ejb.beans.workflow.RouteEngineBean.java
/** * Deletes a route defined by its unique id. * * @param routeId the route id//from w w w.j a v a 2s . c o m * @throws FxApplicationException if an error occured */ private void deleteRoute(long routeId) throws FxApplicationException { // Create the new step Connection con = null; PreparedStatement stmt = null; final String sql = "DELETE FROM " + TBL_WORKFLOW_ROUTES + " WHERE ID=?"; boolean success = false; try { // Obtain a database connection con = Database.getDbConnection(); // Create the new workflow instance stmt = con.prepareStatement(sql); stmt.setLong(1, routeId); stmt.executeUpdate(); success = true; } catch (SQLException exc) { throw new FxRemoveException(LOG, "ex.routes.delete", exc, routeId, exc.getMessage()); } finally { Database.closeObjects(RouteEngineBean.class, con, stmt); if (!success) { EJBUtils.rollback(ctx); } else { StructureLoader.reloadWorkflows(FxContext.get().getDivisionId()); } } }
From source file:it.gulch.linuxday.android.services.AlarmIntentService.java
private void disableAlarms() { // Cancel alarms of every bookmark in the future try {//from ww w .ja v a 2 s.c o m List<Bookmark> bookmarks = bookmarkManager.getBookmarks(new Date()); for (Bookmark bookmark : bookmarks) { long eventId = bookmark.getEvent().getId(); alarmManager.cancel(getAlarmPendingIntent(eventId)); } } catch (SQLException e) { Log.e(TAG, e.getMessage(), e); } }
From source file:mobi.nordpos.catalog.action.ProductCreateActionBean.java
@ValidationMethod(on = { "add" }) public void validateProductNameIsUnique(ValidationErrors errors) { String name = getProduct().getName(); if (name != null && !name.isEmpty()) { try {//from ww w . ja v a 2s . c o m productPersist.init(getDataBaseConnection()); if (productPersist.find(Product.NAME, name) != null) { errors.add("product.name", new SimpleError(getLocalizationKey("error.Product.AlreadyExists"), name)); } } catch (SQLException ex) { getContext().getValidationErrors().addGlobalError(new SimpleError(ex.getMessage())); } } }
From source file:mobi.nordpos.catalog.action.ProductCreateActionBean.java
@ValidationMethod(on = { "add" }) public void validateProductCodeIsUnique(ValidationErrors errors) { String code = getProduct().getCode(); if (code != null && !code.isEmpty()) { try {/*w ww . ja va 2s.c o m*/ productPersist.init(getDataBaseConnection()); if (productPersist.find(Product.CODE, code) != null) { errors.add("product.code", new SimpleError(getLocalizationKey("error.Product.AlreadyExists"), code)); } } catch (SQLException ex) { getContext().getValidationErrors().addGlobalError(new SimpleError(ex.getMessage())); } } }
From source file:com.recomdata.transmart.data.export.util.FileWriterUtil.java
public String getClobAsString(Clob clob) { String strVal = ""; Reader reader = null;//from w w w . j av a 2s. com StringBuffer strBuf = null; try { if (null != clob) { Long clobLength = (null != clob) ? clob.length() : 0; reader = clob.getCharacterStream(); if (null != clobLength && clobLength > 0 && null != reader) { //Here length of String is being rounded to 5000 * n, this is because the buffer size is 5000 //Sometimes the cloblength is less than 5000 * n char[] buffer = new char[clobLength.intValue()]; @SuppressWarnings("unused") int count = 0; strBuf = new StringBuffer(); while ((count = reader.read(buffer)) > 0) { strBuf.append(buffer); } strVal = strBuf.toString(); } } } catch (IOException e) { log.info(e.getMessage()); } catch (SQLException e2) { log.info("SQLException :: " + e2.getMessage()); } finally { try { if (null != reader) reader.close(); //Nullify the objects so they become ready for Garbage Collection reader = null; strBuf = null; clob = null; super.finalize(); } catch (IOException e) { log.info("Error closing Reader in getClobAsString"); } catch (Throwable e) { log.info("Error during super.finalize()"); } } return strVal; }
From source file:com.cubusmail.server.user.UserAccountDaoTest.java
@Before public void initDB() { this.userAccountDao = this.applicationContext.getBean(IUserAccountDao.class); this.testUserAccount = this.applicationContext.getBean("testUserAccount", UserAccount.class); this.dataSource = this.applicationContext.getBean(SingleConnectionDataSource.class); DBManager manager = this.applicationContext.getBean(DBManager.class); try {/*from ww w.j a v a2s. c o m*/ manager.initInternalDB(); Long id = this.userAccountDao.saveUserAccount(testUserAccount); Assert.assertNotNull(id); } catch (SQLException e) { log.error(e.getMessage(), e); Assert.fail(e.getMessage()); } catch (IOException e) { log.error(e.getMessage(), e); Assert.fail(e.getMessage()); } }
From source file:pl.edu.agh.iosr.lsf.RootController.java
@RequestMapping(value = "keyword", method = RequestMethod.GET) public List<String[]> listKeywords() { try {//from w w w. j av a 2 s .c o m return dh.listKeywords(); } catch (SQLException e) { return Collections.singletonList(new String[] { e.getMessage() }); } }