当前位置: 首页>>代码示例>>Java>>正文


Java SQLExceptionTranslator类代码示例

本文整理汇总了Java中org.springframework.jdbc.support.SQLExceptionTranslator的典型用法代码示例。如果您正苦于以下问题:Java SQLExceptionTranslator类的具体用法?Java SQLExceptionTranslator怎么用?Java SQLExceptionTranslator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SQLExceptionTranslator类属于org.springframework.jdbc.support包,在下文中一共展示了SQLExceptionTranslator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SpringSessionSynchronization

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
public SpringSessionSynchronization(
		SessionHolder sessionHolder, SessionFactory sessionFactory,
		SQLExceptionTranslator jdbcExceptionTranslator, boolean newSession) {

	this.sessionHolder = sessionHolder;
	this.sessionFactory = sessionFactory;
	this.jdbcExceptionTranslator = jdbcExceptionTranslator;
	this.newSession = newSession;

	// Check whether the SessionFactory has a JTA TransactionManager.
	TransactionManager jtaTm =
			SessionFactoryUtils.getJtaTransactionManager(sessionFactory, sessionHolder.getAnySession());
	if (jtaTm != null) {
		this.hibernateTransactionCompletion = true;
		// Fetch current JTA Transaction object
		// (just necessary for JTA transaction suspension, with an individual
		// Hibernate Session per currently active/suspended transaction).
		try {
			this.jtaTransaction = jtaTm.getTransaction();
		}
		catch (SystemException ex) {
			throw new DataAccessResourceFailureException("Could not access JTA transaction", ex);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:SpringSessionSynchronization.java

示例2: getDefaultJdbcExceptionTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Obtain a default SQLExceptionTranslator, lazily creating it if necessary.
 * <p>Creates a default
 * {@link org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator}
 * for the SessionFactory's underlying DataSource.
 */
protected synchronized SQLExceptionTranslator getDefaultJdbcExceptionTranslator() {
	if (this.defaultJdbcExceptionTranslator == null) {
		this.defaultJdbcExceptionTranslator = SessionFactoryUtils.newJdbcExceptionTranslator(getSessionFactory());
	}
	return this.defaultJdbcExceptionTranslator;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:HibernateAccessor.java

示例3: getDefaultJdbcExceptionTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Obtain a default SQLExceptionTranslator, lazily creating it if necessary.
 * <p>Creates a default
 * {@link org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator}
 * for the SessionFactory's underlying DataSource.
 */
protected synchronized SQLExceptionTranslator getDefaultJdbcExceptionTranslator() {
	if (this.defaultJdbcExceptionTranslator == null) {
		if (getDataSource() != null) {
			this.defaultJdbcExceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(getDataSource());
		}
		else {
			this.defaultJdbcExceptionTranslator = SessionFactoryUtils.newJdbcExceptionTranslator(getSessionFactory());
		}
	}
	return this.defaultJdbcExceptionTranslator;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:HibernateTransactionManager.java

示例4: StoredProcedureExceptionTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
public StoredProcedureExceptionTranslator(DataSource ds) {
	setDataSource(ds);
	setSql(SQL);
	getJdbcTemplate().setExceptionTranslator(new SQLExceptionTranslator() {

		@Override
		public DataAccessException translate(String task, String sql,
				SQLException sqlex) {
			return new CustomDataException(sql, sqlex);
		}

	});
	compile();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:StoredProcedureTests.java

示例5: getTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
private SQLExceptionTranslator getTranslator(ExecuteContext context) {
	SQLDialect dialect = context.configuration().dialect();
	if (dialect != null && dialect.thirdParty() != null) {
		return new SQLErrorCodeSQLExceptionTranslator(
				dialect.thirdParty().springDbName());
	}
	return new SQLStateSQLExceptionTranslator();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:JooqExceptionTranslator.java

示例6: handle

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Handle a single exception in the chain. SQLExceptions might be nested multiple
 * levels deep. The outermost exception is usually the least interesting one (
 * "Call getNextException to see the cause."). Therefore the innermost exception is
 * propagated and all other exceptions are logged.
 * @param context the execute context
 * @param translator the exception translator
 * @param exception the exception
 */
private void handle(ExecuteContext context, SQLExceptionTranslator translator,
		SQLException exception) {
	DataAccessException translated = translate(context, translator, exception);
	if (exception.getNextException() == null) {
		context.exception(translated);
	}
	else {
		logger.error("Execution of SQL statement failed.", translated);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:JooqExceptionTranslator.java

示例7: getTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
private SQLExceptionTranslator getTranslator(ExecuteContext context) {
	SQLDialect dialect = context.configuration().dialect();
	if (dialect != null) {
		return new SQLErrorCodeSQLExceptionTranslator(dialect.name());
	}
	return new SQLStateSQLExceptionTranslator();
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:8,代码来源:JooqExceptionTranslator.java

示例8: main

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    DataSource ds = getDataSourceMysql();
    SQLErrorCodesFactory sqlErrorCodesFactory = SQLErrorCodesFactory.getInstance();
    SQLExceptionTranslator sqlExTrans = new SQLErrorCodeSQLExceptionTranslator(
            sqlErrorCodesFactory.getErrorCodes(ds));
    try {
        qndMysqlPK(ds.getConnection());
    } catch (SQLException e) {
        System.out.println(sqlExTrans.translate(null, null, e));
        e.printStackTrace();
    }
}
 
开发者ID:DDTH,项目名称:ddth-dao,代码行数:13,代码来源:QndSQLExceptionTranslator.java

示例9: getDefaultJdbcExceptionTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Obtain a default SQLExceptionTranslator, lazily creating it if necessary.
 * <p>Creates a default
 * {@link org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator}
 * for the SessionFactory's underlying DataSource.
 */
protected synchronized SQLExceptionTranslator getDefaultJdbcExceptionTranslator() {
	if (this.defaultJdbcExceptionTranslator == null) {
		this.defaultJdbcExceptionTranslator = TransactionManagerUtils.newJdbcExceptionTranslator();
	}
	return this.defaultJdbcExceptionTranslator;
}
 
开发者ID:ryanwli,项目名称:guzz,代码行数:13,代码来源:SpringWriteTemplate.java

示例10: StreamResultSetExtractor

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Constructs an extractor.
 *
 * @param sql the SQL
 * @param mapper the row mapper
 * @param handleStream the handler function which extracts a result from the row stream
 * @param excTranslator the translator of SQL to DataAccessException
 */
public StreamResultSetExtractor(
        String sql,
        RowMapper<T> mapper,
        Function<? super Stream<T>, U> handleStream,
        SQLExceptionTranslator excTranslator) {
    this.sql = sql;
    this.mapper = mapper;
    this.handleStream = handleStream;
    this.excTranslator = excTranslator;
}
 
开发者ID:cero-t,项目名称:sqltemplate,代码行数:19,代码来源:StreamResultSetExtractor.java

示例11: ResultSetIterator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Constructs an iterator.
 *
 * @param sql the SQL
 * @param rs the result set to iterate over
 * @param mapper the mapper which converts each row
 * @param excTranslator the translator of {@link SQLException}s.
 */
ResultSetIterator(
        String sql,
        ResultSet rs,
        RowMapper<T> mapper,
        SQLExceptionTranslator excTranslator) {
    this.sql = sql;
    this.rs = rs;
    this.mapper = mapper;
    this.excTranslator = excTranslator;
}
 
开发者ID:cero-t,项目名称:sqltemplate,代码行数:19,代码来源:ResultSetIterator.java

示例12: queryStreamWithOrdinalParams

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Executes a quey for stream with ordinal parameters.
 */
private <T, U> U queryStreamWithOrdinalParams(
        String sql,
        PreparedStatementSetter pss,
        RowMapper<T> mapper,
        Function<? super Stream<T>, U> handleStream) {
    SQLExceptionTranslator excTranslator = jdbcTemplate.getExceptionTranslator();
    ResultSetExtractor<U> extractor
        = new StreamResultSetExtractor(sql, mapper, handleStream, excTranslator);
    return jdbcTemplate.query(sql, pss, extractor);
}
 
开发者ID:cero-t,项目名称:sqltemplate,代码行数:14,代码来源:SqlTemplate.java

示例13: queryStreamWithNamedParams

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
/**
 * Executes a query for stream with named parameters.
 */
private <T, U> U queryStreamWithNamedParams(
        String sql,
        SqlParameterSource sps,
        RowMapper<T> mapper,
        Function<? super Stream<T>, U> handleStream) {
    SQLExceptionTranslator excTranslator = jdbcTemplate.getExceptionTranslator();
    ResultSetExtractor<U> extractor
        = new StreamResultSetExtractor(sql, mapper, handleStream, excTranslator);
    return namedJdbcTemplate.query(sql, sps, extractor);
}
 
开发者ID:cero-t,项目名称:sqltemplate,代码行数:14,代码来源:SqlTemplate.java

示例14: setExceptionTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
public void setExceptionTranslator(
    SQLExceptionTranslator exceptionTranslator) {
  delegate.setExceptionTranslator(exceptionTranslator);
}
 
开发者ID:tramchamploo,项目名称:buffer-slayer,代码行数:5,代码来源:BatchJdbcTemplate.java

示例15: getExceptionTranslator

import org.springframework.jdbc.support.SQLExceptionTranslator; //导入依赖的package包/类
public SQLExceptionTranslator getExceptionTranslator() {
  return delegate.getExceptionTranslator();
}
 
开发者ID:tramchamploo,项目名称:buffer-slayer,代码行数:4,代码来源:BatchJdbcTemplate.java


注:本文中的org.springframework.jdbc.support.SQLExceptionTranslator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。