org.springframework.jdbc.core.JdbcTemplate.createConnectionProxy()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.springframework.jdbc.core.JdbcTemplate.createConnectionProxy()方法的一些代码示例,展示了JdbcTemplate.createConnectionProxy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JdbcTemplate.createConnectionProxy()方法的具体详情如下:
包路径:org.springframework.jdbc.core.JdbcTemplate
类名称:JdbcTemplate
方法名:createConnectionProxy

JdbcTemplate.createConnectionProxy介绍

[英]Create a close-suppressing proxy for the given JDBC Connection. Called by the execute method.

The proxy also prepares returned JDBC Statements, applying statement settings such as fetch size, max rows, and query timeout.
[中]为给定的JDBC连接创建关闭代理。由execute方法调用。
代理还准备返回的JDBC语句,应用语句设置,如fetch size、max rows和查询超时。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T execute(ConnectionCallback<T> action) throws DataAccessException {
  Assert.notNull(action, "Callback object must not be null");
  Connection con = DataSourceUtils.getConnection(obtainDataSource());
  try {
    // Create close-suppressing Connection proxy, also preparing returned Statements.
    Connection conToUse = createConnectionProxy(con);
    return action.doInConnection(conToUse);
  }
  catch (SQLException ex) {
    // Release Connection early, to avoid potential connection pool deadlock
    // in the case when the exception translator hasn't been initialized yet.
    String sql = getSql(action);
    DataSourceUtils.releaseConnection(con, getDataSource());
    con = null;
    throw translateException("ConnectionCallback", sql, ex);
  }
  finally {
    DataSourceUtils.releaseConnection(con, getDataSource());
  }
}

代码示例来源:origin: org.springframework/org.springframework.jdbc

public <T> T execute(ConnectionCallback<T> action) throws DataAccessException {
  Assert.notNull(action, "Callback object must not be null");
  Connection con = DataSourceUtils.getConnection(getDataSource());
  try {
    Connection conToUse = con;
    if (this.nativeJdbcExtractor != null) {
      // Extract native JDBC Connection, castable to OracleConnection or the like.
      conToUse = this.nativeJdbcExtractor.getNativeConnection(con);
    }
    else {
      // Create close-suppressing Connection proxy, also preparing returned Statements.
      conToUse = createConnectionProxy(con);
    }
    return action.doInConnection(conToUse);
  }
  catch (SQLException ex) {
    // Release Connection early, to avoid potential connection pool deadlock
    // in the case when the exception translator hasn't been initialized yet.
    DataSourceUtils.releaseConnection(con, getDataSource());
    con = null;
    throw getExceptionTranslator().translate("ConnectionCallback", getSql(action), ex);
  }
  finally {
    DataSourceUtils.releaseConnection(con, getDataSource());
  }
}

代码示例来源:origin: apache/servicemix-bundles

try {
  Connection conToUse = createConnectionProxy(con);
  return action.doInConnection(conToUse);

相关文章