List of usage examples for java.sql SQLException getSQLState
public String getSQLState()
SQLException
object. From source file:org.josso.gateway.identity.service.store.db.DataSourceIdentityStore.java
/** * Opens a new DB Connection, retrieved from the DS. * * @throws SSOIdentityException//from w w w .j a v a2 s .c om */ protected Connection getDBConnection() throws SSOIdentityException { try { return getDataSource().getConnection(); } catch (SQLException e) { logger.error("[getDBConnection()]:" + e.getErrorCode() + "/" + e.getSQLState() + "]" + e.getMessage()); throw new SSOIdentityException("Exception while getting connection: \n " + e.getMessage()); } }
From source file:it.larusba.neo4j.jdbc.http.driver.Neo4jResponse.java
/** * Transform the error list to a string for display purpose. * * @return A String with all errors// w w w . ja v a 2s . com */ public String displayErrors() { StringBuffer sb = new StringBuffer(); if (hasErrors()) { sb.append("Some errors occurred : \n"); for (SQLException error : errors) { sb.append("[").append(error.getSQLState()).append("]").append(":").append(error.getMessage()) .append("\n"); } } return sb.toString(); }
From source file:org.neo4j.jdbc.http.driver.Neo4jResponse.java
/** * Transform the error list to a string for display purpose. * * @return A String with all errors//from w ww . j a v a 2 s . c o m */ public String displayErrors() { StringBuilder sb = new StringBuilder(); if (hasErrors()) { sb.append("Some errors occurred : \n"); for (SQLException error : errors) { sb.append("[").append(error.getSQLState()).append("]").append(":").append(error.getMessage()) .append("\n"); } } return sb.toString(); }
From source file:com.espertech.esper.epl.db.DatabaseDSFactoryConnFactory.java
public Connection getConnection() throws DatabaseConfigException { Connection connection;//from www . j a v a 2 s .c om try { connection = dataSource.getConnection(); } catch (SQLException ex) { String detail = "SQLException: " + ex.getMessage() + " SQLState: " + ex.getSQLState() + " VendorError: " + ex.getErrorCode(); throw new DatabaseConfigException( "Error obtaining database connection using datasource " + "with detail " + detail, ex); } DatabaseDMConnFactory.setConnectionOptions(connection, connectionSettings); return connection; }
From source file:com.pontecultural.flashcards.WebServicesController.java
/** * Fetch cards for deck. //from w w w . ja v a2 s . com */ @RequestMapping(value = "/deckId/{deckId}/cards.json", method = RequestMethod.GET) public String getCards(HttpServletRequest req, @PathVariable Integer deckId, Model model) { logger.info("get cards for deck: " + deckId); try { model.addAttribute("flashcards", jdbcFlashcardsDao.fetchCardsByDeck(deckId)); } catch (DataAccessException e) { SQLException sqle = (SQLException) e.getCause(); logger.error("Error code: " + sqle.getErrorCode()); logger.error("SQL state: " + sqle.getSQLState()); logger.error("Error msg: " + sqle.getMessage()); model.addAttribute("flashcards", null); } return "flashcardstemplate"; // was "observationtemplate" - do I need to configure this someone? }
From source file:org.dcache.chimera.H2FsSqlDriver.java
@Override public boolean isForeignKeyError(SQLException e) { return "23506".endsWith(e.getSQLState()); }
From source file:com.flexive.core.storage.MySQL.MySQLTreeStorage.java
/** * {@inheritDoc}/*w w w .ja va 2s . c o m*/ */ @Override public List<String> getLabels(Connection con, FxTreeMode mode, long labelPropertyId, FxLanguage language, boolean stripNodeInfos, long... nodeIds) throws FxApplicationException { List<String> ret = new ArrayList<String>(nodeIds.length); if (nodeIds.length == 0) return ret; PreparedStatement ps = null; ResultSet rs; try { ps = con.prepareStatement("SELECT tree_FTEXT1024_Chain(?,?,?,?)"); ps.setInt(2, (int) language.getId()); ps.setLong(3, labelPropertyId); ps.setBoolean(4, mode == FxTreeMode.Live); for (long id : nodeIds) { ps.setLong(1, id); try { rs = ps.executeQuery(); if (rs != null && rs.next()) { final String path = rs.getString(1); if (!StringUtils.isEmpty(path)) ret.add(stripNodeInfos ? stripNodeInfos(path) : path); else addUnknownNodeId(ret, id); } else addUnknownNodeId(ret, id); } catch (SQLException e) { if ("22001".equals(e.getSQLState())) { //invalid node id in MySQL addUnknownNodeId(ret, id); } else throw e; } } return ret; } catch (SQLException e) { throw new FxLoadException(LOG, e, "ex.db.sqlError", e.getMessage()); } finally { try { if (ps != null) ps.close(); } catch (Exception e) { //ignore } } }
From source file:org.apache.synapse.samples.framework.DerbyServerController.java
public boolean stopProcess() { log.info("Shutting down Derby server..."); try {//from w w w . j a va 2 s . c o m try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); } catch (SQLException se) { if (se.getErrorCode() == 50000 && "XJ015".equals(se.getSQLState())) { // we got the expected exception log.info("Derby shut down normally"); } } server.shutdown(); FileUtils.deleteDirectory(new File("./synapsedb")); return true; } catch (Exception e) { log.warn("Error while trying to delete database directory", e); return false; } }
From source file:org.apache.wookie.tests.beans.JPAPersistenceTest.java
/** * Tear down JPA persistence runtime test environment. * // w w w.j a v a 2 s.com * @throws Exception */ @After public void tearDownPerTest() throws Exception { configured = false; logger.info("JPA tear down test"); // terminate persistence manager factory PersistenceManagerFactory.terminate(); // unbind datasource from JNDI context rootContext.unbind(JPAPersistenceManager.WIDGET_DATABASE_JNDI_DATASOURCE_FULL_NAME); // shutdown datasource pool connectionPool.close(); // special shutdown handling for derby if (dbDriver.equals("org.apache.derby.jdbc.EmbeddedDriver") && dbUri.startsWith("jdbc:derby:") && dbType.equals("derby")) { // derby shutdown connection String shutdownDBUri = dbUri; int parametersIndex = shutdownDBUri.indexOf(";"); if (parametersIndex != -1) { shutdownDBUri = shutdownDBUri.substring(0, parametersIndex); } shutdownDBUri += ";shutdown=true"; try { DriverManager.getConnection(shutdownDBUri, dbUser, dbPassword); throw new SQLException("Derby database not shutdown"); } catch (SQLException sqle) { if (!sqle.getSQLState().equals("08006") && !sqle.getSQLState().equals("XJ015")) { throw sqle; } } } logger.info("JPA test torn down"); }
From source file:com.nabla.wapp.server.dispatch.DispatchService.java
private <A extends IAction<R>, R extends IResult> R dispatch(A action, final UserSession session) throws DispatchException { if (log.isTraceEnabled()) log.trace("handling command '" + action.getClass().getSimpleName() + "'"); IActionHandler<A, R> handler = handlers.findHandler(action); if (handler == null) throw new UnsupportedActionException(action); try {/*from w w w.j a v a 2s .co m*/ final IUserSessionContext ctx = ctxFactory.get(session, handler.requireWriteContext()); try { return handler.execute(action, ctx); } finally { ctx.close(); } } catch (final SQLException e) { if (log.isErrorEnabled()) log.error("SQL error " + e.getErrorCode() + "-" + e.getSQLState(), e); throw new InternalErrorException(Util.formatInternalErrorDescription(e)); } catch (DispatchException e) { if (log.isErrorEnabled()) log.error("internal error", e); throw e; } catch (Throwable e) { if (log.isErrorEnabled()) log.error("internal error", e); throw new InternalErrorException(Util.formatInternalErrorDescription(e)); } }