org.apache.ibatis.logging.Log Java Examples
The following examples show how to use
org.apache.ibatis.logging.Log.
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 File: ReuseExecutor.java From mybatis with Apache License 2.0 | 6 votes |
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException { Statement stmt; //得到绑定的SQL语句 BoundSql boundSql = handler.getBoundSql(); String sql = boundSql.getSql(); //如果缓存中已经有了,直接得到Statement if (hasStatementFor(sql)) { stmt = getStatement(sql); } else { //如果缓存没有找到,则和SimpleExecutor处理完全一样,然后加入缓存 Connection connection = getConnection(statementLog); stmt = handler.prepare(connection); putStatement(sql, stmt); } handler.parameterize(stmt); return stmt; }
Example #2
Source File: BindingLogPlugin32.java From pinpoint with Apache License 2.0 | 6 votes |
private void bindingLog(Invocation invocation) throws SQLException { Object[] args = invocation.getArgs(); MappedStatement ms = (MappedStatement) args[0]; Object parameterObject = args[1]; StatementType statementType = ms.getStatementType(); if (StatementType.PREPARED == statementType || StatementType.CALLABLE == statementType) { Log statementLog = ms.getStatementLog(); if (isDebugEnable(statementLog)) { BoundSql boundSql = ms.getBoundSql(parameterObject); String sql = boundSql.getSql(); List<String> parameterList = getParameters(ms, parameterObject, boundSql); debug(statementLog, "==> BindingLog: " + bindLogFormatter.format(sql, parameterList)); } } }
Example #3
Source File: ReuseExecutor.java From mybaties with Apache License 2.0 | 6 votes |
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException { Statement stmt; //得到绑定的SQL语句 BoundSql boundSql = handler.getBoundSql(); String sql = boundSql.getSql(); //如果缓存中已经有了,直接得到Statement if (hasStatementFor(sql)) { stmt = getStatement(sql); } else { //如果缓存没有找到,则和SimpleExecutor处理完全一样,然后加入缓存 Connection connection = getConnection(statementLog); stmt = handler.prepare(connection); putStatement(sql, stmt); } handler.parameterize(stmt); return stmt; }
Example #4
Source File: SimpleExecutor.java From mybatis with Apache License 2.0 | 5 votes |
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException { Statement stmt; Connection connection = getConnection(statementLog); //调用StatementHandler.prepare stmt = handler.prepare(connection); //调用StatementHandler.parameterize handler.parameterize(stmt); return stmt; }
Example #5
Source File: BaseExecutor.java From mybatis with Apache License 2.0 | 5 votes |
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 #6
Source File: BaseJdbcLogger.java From mybatis with Apache License 2.0 | 5 votes |
public BaseJdbcLogger(Log log, int queryStack) { this.statementLog = log; if (queryStack == 0) { this.queryStack = 1; } else { this.queryStack = queryStack; } }
Example #7
Source File: Configuration.java From mybatis with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void setLogImpl(Class<?> logImpl) { if (logImpl != null) { this.logImpl = (Class<? extends Log>) logImpl; LogFactory.useCustomLogging(this.logImpl); } }
Example #8
Source File: BindingLogPlugin32.java From pinpoint with Apache License 2.0 | 5 votes |
public void debug(Log statementLogger, String msg) { if (statementLogger.isDebugEnabled()) { statementLogger.debug(msg); } else { pLogger.debug(msg); } }
Example #9
Source File: SimpleExecutor.java From mybaties with Apache License 2.0 | 5 votes |
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException { Statement stmt; Connection connection = getConnection(statementLog); //调用StatementHandler.prepare stmt = handler.prepare(connection); //调用StatementHandler.parameterize handler.parameterize(stmt); return stmt; }
Example #10
Source File: BaseExecutor.java From mybaties with Apache License 2.0 | 5 votes |
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 #11
Source File: BaseJdbcLogger.java From mybaties with Apache License 2.0 | 5 votes |
public BaseJdbcLogger(Log log, int queryStack) { this.statementLog = log; if (queryStack == 0) { this.queryStack = 1; } else { this.queryStack = queryStack; } }
Example #12
Source File: Configuration.java From mybaties with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void setLogImpl(Class<?> logImpl) { if (logImpl != null) { this.logImpl = (Class<? extends Log>) logImpl; LogFactory.useCustomLogging(this.logImpl); } }
Example #13
Source File: SQLHelper.java From Shop-for-JavaWeb with MIT License | 5 votes |
/** * 查询总纪录数 * @param sql SQL语句 * @param connection 数据库连接 * @param mappedStatement mapped * @param parameterObject 参数 * @param boundSql boundSql * @return 总记录数 * @throws SQLException sql查询错误 */ public static int getCount(final String sql, final Connection connection, final MappedStatement mappedStatement, final Object parameterObject, final BoundSql boundSql, Log log) throws SQLException { final String countSql = "select count(1) from (" + sql + ") tmp_count"; // final String countSql = "select count(1) " + removeSelect(removeOrders(sql)); Connection conn = connection; PreparedStatement ps = null; ResultSet rs = null; try { if (log.isDebugEnabled()) { log.debug("COUNT SQL: " + StringUtils.replaceEach(countSql, new String[]{"\n", "\t"}, new String[]{" ", " "})); } if (conn == null){ conn = mappedStatement.getConfiguration().getEnvironment().getDataSource().getConnection(); } ps = conn.prepareStatement(countSql); BoundSql countBS = new BoundSql(mappedStatement.getConfiguration(), countSql, boundSql.getParameterMappings(), parameterObject); SQLHelper.setParameters(ps, mappedStatement, countBS, parameterObject); rs = ps.executeQuery(); int count = 0; if (rs.next()) { count = rs.getInt(1); } return count; } finally { if (rs != null) { rs.close(); } if (ps != null) { ps.close(); } if (conn != null) { conn.close(); } } }
Example #14
Source File: Configuration.java From Shop-for-JavaWeb with MIT License | 5 votes |
@SuppressWarnings("unchecked") public void setLogImpl(Class<?> logImpl) { if (logImpl != null) { this.logImpl = (Class<? extends Log>) logImpl; LogFactory.useCustomLogging(this.logImpl); } }
Example #15
Source File: PreparedStatementLogger.java From mybaties with Apache License 2.0 | 4 votes |
public static PreparedStatement newInstance(PreparedStatement stmt, Log statementLog, int queryStack) { InvocationHandler handler = new PreparedStatementLogger(stmt, statementLog, queryStack); ClassLoader cl = PreparedStatement.class.getClassLoader(); return (PreparedStatement) Proxy.newProxyInstance(cl, new Class[]{PreparedStatement.class, CallableStatement.class}, handler); }
Example #16
Source File: BaseJdbcLogger.java From wangsy-january with Apache License 2.0 | 4 votes |
public BaseJdbcLogger(Log log) { this.statementLog = log; }
Example #17
Source File: ResultLoaderMap.java From mybatis with Apache License 2.0 | 4 votes |
private Log getLogger() { if (this.log == null) { this.log = LogFactory.getLog(this.getClass()); } return this.log; }
Example #18
Source File: BaseJdbcLogger.java From wangsy-january with Apache License 2.0 | 4 votes |
public Log getStatementLog() { return this.statementLog; }
Example #19
Source File: ConnectionLogger.java From mybatis with Apache License 2.0 | 4 votes |
public static Connection newInstance(Connection conn, Log statementLog, int queryStack) { InvocationHandler handler = new ConnectionLogger(conn, statementLog, queryStack); ClassLoader cl = Connection.class.getClassLoader(); return (Connection) Proxy.newProxyInstance(cl, new Class[]{Connection.class}, handler); }
Example #20
Source File: ConnectionLogger.java From mybatis with Apache License 2.0 | 4 votes |
private ConnectionLogger(Connection conn, Log statementLog, int queryStack) { super(statementLog, queryStack); this.connection = conn; }
Example #21
Source File: Configuration.java From Shop-for-JavaWeb with MIT License | 4 votes |
public Class<? extends Log> getLogImpl() { return logImpl; }
Example #22
Source File: ResultSetLogger.java From mybatis with Apache License 2.0 | 4 votes |
public static ResultSet newInstance(ResultSet rs, Log statementLog, int queryStack) { InvocationHandler handler = new ResultSetLogger(rs, statementLog, queryStack); ClassLoader cl = ResultSet.class.getClassLoader(); return (ResultSet) Proxy.newProxyInstance(cl, new Class[]{ResultSet.class}, handler); }
Example #23
Source File: ResultSetLogger.java From mybatis with Apache License 2.0 | 4 votes |
private ResultSetLogger(ResultSet rs, Log statementLog, int queryStack) { super(statementLog, queryStack); this.rs = rs; }
Example #24
Source File: PreparedStatementLogger.java From mybatis with Apache License 2.0 | 4 votes |
public static PreparedStatement newInstance(PreparedStatement stmt, Log statementLog, int queryStack) { InvocationHandler handler = new PreparedStatementLogger(stmt, statementLog, queryStack); ClassLoader cl = PreparedStatement.class.getClassLoader(); return (PreparedStatement) Proxy.newProxyInstance(cl, new Class[]{PreparedStatement.class, CallableStatement.class}, handler); }
Example #25
Source File: PreparedStatementLogger.java From mybatis with Apache License 2.0 | 4 votes |
private PreparedStatementLogger(PreparedStatement stmt, Log statementLog, int queryStack) { super(statementLog, queryStack); this.statement = stmt; }
Example #26
Source File: StatementLogger.java From mybatis with Apache License 2.0 | 4 votes |
public static Statement newInstance(Statement stmt, Log statementLog, int queryStack) { InvocationHandler handler = new StatementLogger(stmt, statementLog, queryStack); ClassLoader cl = Statement.class.getClassLoader(); return (Statement) Proxy.newProxyInstance(cl, new Class[]{Statement.class}, handler); }
Example #27
Source File: StatementLogger.java From mybatis with Apache License 2.0 | 4 votes |
private StatementLogger(Statement stmt, Log statementLog, int queryStack) { super(statementLog, queryStack); this.statement = stmt; }
Example #28
Source File: Configuration.java From mybatis with Apache License 2.0 | 4 votes |
public Class<? extends Log> getLogImpl() { return logImpl; }
Example #29
Source File: MappedStatement.java From mybatis with Apache License 2.0 | 4 votes |
public Log getStatementLog() { return statementLog; }
Example #30
Source File: BindingLogPlugin32.java From pinpoint with Apache License 2.0 | 4 votes |
public boolean isDebugEnable(Log statementLogger) { return statementLogger.isDebugEnabled() || pLogger.isDebugEnabled(); }