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 Project: mybaties Author: shurun19851206 File: ReuseExecutor.java License: 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 Project: pinpoint Author: naver File: BindingLogPlugin32.java License: 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 Project: mybatis Author: tuguangquan File: ReuseExecutor.java License: 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 Project: Shop-for-JavaWeb Author: EleTeam File: Configuration.java License: 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 #5
Source Project: Shop-for-JavaWeb Author: EleTeam File: SQLHelper.java License: 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 #6
Source Project: mybaties Author: shurun19851206 File: Configuration.java License: 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 #7
Source Project: mybaties Author: shurun19851206 File: BaseJdbcLogger.java License: 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 #8
Source Project: mybaties Author: shurun19851206 File: BaseExecutor.java License: 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 #9
Source Project: mybaties Author: shurun19851206 File: SimpleExecutor.java License: 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 Project: pinpoint Author: naver File: BindingLogPlugin32.java License: Apache License 2.0 | 5 votes |
public void debug(Log statementLogger, String msg) { if (statementLogger.isDebugEnabled()) { statementLogger.debug(msg); } else { pLogger.debug(msg); } }
Example #11
Source Project: mybatis Author: tuguangquan File: Configuration.java License: 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 #12
Source Project: mybatis Author: tuguangquan File: BaseJdbcLogger.java License: 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 #13
Source Project: mybatis Author: tuguangquan File: BaseExecutor.java License: 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 #14
Source Project: mybatis Author: tuguangquan File: SimpleExecutor.java License: 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 #15
Source Project: wangsy-january Author: hellosmile01 File: BaseJdbcLogger.java License: Apache License 2.0 | 4 votes |
public BaseJdbcLogger(Log log) { this.statementLog = log; }
Example #16
Source Project: wangsy-january Author: hellosmile01 File: BaseJdbcLogger.java License: Apache License 2.0 | 4 votes |
public Log getStatementLog() { return this.statementLog; }
Example #17
Source Project: Shop-for-JavaWeb Author: EleTeam File: Configuration.java License: MIT License | 4 votes |
public Class<? extends Log> getLogImpl() { return logImpl; }
Example #18
Source Project: mybaties Author: shurun19851206 File: MappedStatement.java License: Apache License 2.0 | 4 votes |
public Log getStatementLog() { return statementLog; }
Example #19
Source Project: mybaties Author: shurun19851206 File: Configuration.java License: Apache License 2.0 | 4 votes |
public Class<? extends Log> getLogImpl() { return logImpl; }
Example #20
Source Project: mybaties Author: shurun19851206 File: StatementLogger.java License: Apache License 2.0 | 4 votes |
private StatementLogger(Statement stmt, Log statementLog, int queryStack) { super(statementLog, queryStack); this.statement = stmt; }
Example #21
Source Project: mybaties Author: shurun19851206 File: StatementLogger.java License: 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 #22
Source Project: mybaties Author: shurun19851206 File: PreparedStatementLogger.java License: Apache License 2.0 | 4 votes |
private PreparedStatementLogger(PreparedStatement stmt, Log statementLog, int queryStack) { super(statementLog, queryStack); this.statement = stmt; }
Example #23
Source Project: mybaties Author: shurun19851206 File: PreparedStatementLogger.java License: 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 #24
Source Project: mybaties Author: shurun19851206 File: ResultSetLogger.java License: Apache License 2.0 | 4 votes |
private ResultSetLogger(ResultSet rs, Log statementLog, int queryStack) { super(statementLog, queryStack); this.rs = rs; }
Example #25
Source Project: mybaties Author: shurun19851206 File: ResultSetLogger.java License: 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 #26
Source Project: mybaties Author: shurun19851206 File: ConnectionLogger.java License: Apache License 2.0 | 4 votes |
private ConnectionLogger(Connection conn, Log statementLog, int queryStack) { super(statementLog, queryStack); this.connection = conn; }
Example #27
Source Project: mybaties Author: shurun19851206 File: ConnectionLogger.java License: 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 #28
Source Project: mybaties Author: shurun19851206 File: ResultLoaderMap.java License: Apache License 2.0 | 4 votes |
private Log getLogger() { if (this.log == null) { this.log = LogFactory.getLog(this.getClass()); } return this.log; }
Example #29
Source Project: pinpoint Author: naver File: BindingLogPlugin32.java License: Apache License 2.0 | 4 votes |
public boolean isDebugEnable(Log statementLogger) { return statementLogger.isDebugEnabled() || pLogger.isDebugEnabled(); }
Example #30
Source Project: mybatis Author: tuguangquan File: MappedStatement.java License: Apache License 2.0 | 4 votes |
public Log getStatementLog() { return statementLog; }