List of usage examples for org.springframework.jdbc.support SQLErrorCodeSQLExceptionTranslator SQLErrorCodeSQLExceptionTranslator
public SQLErrorCodeSQLExceptionTranslator()
From source file:es.galvarez.rest.config.SpringConfiguration.java
@Bean(name = "jdbcExceptionTranslator") public SQLErrorCodeSQLExceptionTranslator jdbcExceptionTranslator() { SQLErrorCodeSQLExceptionTranslator exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(); exceptionTranslator.setDataSource(configureDataSource()); return exceptionTranslator; }
From source file:com.alibaba.cobar.client.support.execution.DefaultConcurrentRequestProcessor.java
protected Object executeWith(Connection connection, SqlMapClientCallback action) { SqlMapSession session = getSqlMapClient().openSession(); try {/* w w w.j a va 2 s.co m*/ try { session.setUserConnection(connection); } catch (SQLException e) { throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", e); } try { return action.doInSqlMapClient(session); } catch (SQLException ex) { throw new SQLErrorCodeSQLExceptionTranslator().translate("SqlMapClient operation", null, ex); } } finally { session.close(); } }
From source file:com.alibaba.cobar.client.CobarSqlMapClientTemplate.java
protected Object executeWith(DataSource dataSource, SqlMapClientCallback action) { SqlMapSession session = getSqlMapClient().openSession(); try {/*from w ww. jav a2 s. com*/ Connection springCon = null; boolean transactionAware = (dataSource instanceof TransactionAwareDataSourceProxy); // Obtain JDBC Connection to operate on... try { springCon = (transactionAware ? dataSource.getConnection() : DataSourceUtils.doGetConnection(dataSource)); session.setUserConnection(springCon); } catch (SQLException ex) { throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", ex); } try { return action.doInSqlMapClient(session); } catch (SQLException ex) { throw new SQLErrorCodeSQLExceptionTranslator().translate("SqlMapClient operation", null, ex); } catch (Throwable t) { throw new UncategorizedCobarClientException( "unknown excepton when performing data access operation.", t); } finally { try { if (springCon != null) { if (transactionAware) { springCon.close(); } else { DataSourceUtils.doReleaseConnection(springCon, dataSource); } } } catch (Throwable ex) { logger.debug("Could not close JDBC Connection", ex); } } // Processing finished - potentially session still to be closed. } finally { session.close(); } }