Java Code Examples for org.apache.ibatis.logging.jdbc.ConnectionLogger

The following examples show how to use org.apache.ibatis.logging.jdbc.ConnectionLogger. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-boot-mybatis-rw   Source File: RWPlugin.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * MyBatis wraps the JDBC Connection with a logging proxy but Spring registers the original connection so it should
 * be unwrapped before calling {@code DataSourceUtils.isConnectionTransactional(Connection, DataSource)}
 * 
 * @param connection May be a {@code ConnectionLogger} proxy
 * @return the original JDBC {@code Connection}
 */
private Connection unwrapConnection(Connection connection) {
    if (Proxy.isProxyClass(connection.getClass())) {
        InvocationHandler handler = Proxy.getInvocationHandler(connection);
        if (handler instanceof ConnectionLogger) {
            return ((ConnectionLogger) handler).getConnection();
        }
    }
    return connection;
}
 
Example 2
Source Project: mybaties   Source File: BaseExecutor.java    License: Apache License 2.0 5 votes vote down vote up
protected Connection getConnection(Log statementLog) throws SQLException {
  Connection connection = transaction.getConnection();
  if (statementLog.isDebugEnabled()) {
    //如果需要打印Connection的日志,返回一个ConnectionLogger(代理模式, AOP思想)
    return ConnectionLogger.newInstance(connection, statementLog, queryStack);
  } else {
    return connection;
  }
}
 
Example 3
Source Project: mybatis   Source File: BaseExecutor.java    License: Apache License 2.0 5 votes vote down vote up
protected Connection getConnection(Log statementLog) throws SQLException {
  Connection connection = transaction.getConnection();
  if (statementLog.isDebugEnabled()) {
    //如果需要打印Connection的日志,返回一个ConnectionLogger(代理模式, AOP思想)
    return ConnectionLogger.newInstance(connection, statementLog, queryStack);
  } else {
    return connection;
  }
}