精华内容
下载资源
问答
  • log4jdbc

    2019-09-27 00:54:18
    现大家使用的ibatis,hibernate,spring jdbc的sql日志信息,...而log4jdbc是在jdbc层的一个日志框架,可以将占位符与参数全部合并在一起显示,方便直接拷贝sql在PLSQL Developer等客户端直接执行,加快调试速度。 ...

    现大家使用的ibatis,hibernate,spring jdbc的sql日志信息,有一点个缺点是占位符与参数是分开打印的,如果想要拷贝sql至PLSQL Developer客户端直接执行,需要自己拼凑sql。而log4jdbc是在jdbc层的一个日志框架,可以将占位符与参数全部合并在一起显示,方便直接拷贝sql在PLSQL Developer等客户端直接执行,加快调试速度。

     

    .简单介绍:

    1.没有使用log4jdbc前sql显示:

     

    Sql代码  
    1. select username,password from bitth_date > ? and age < ? and username = ?  

     

     

     

    2.使用log4jdbc后sql显示:

     

    Sql代码  
    1. select username,password from bitth_date > to_date(‘2010-11-11’,’yyyy-mm-dd’) and age < 20 and username = ‘qq2008’ {executed in 2 msec}  

     

     

     

            

    这样就可以直接拷贝上面的sql在PLSQL直接执行. 最后的 {executed in 2 msec} 为SQL执行时间.而如果mysql,日志信息将不会出现 to_date()

     

     

    .log4jdbc使用:

     

    1.spring xml配置(拦截需要处理的dataSource连接)

     

     

     

     

     

    Xml代码  
    1. <bean id="log4jdbcInterceptor" class="net.sf.log4jdbc.DataSourceSpyInterceptor" />  
    2.   
    3. <bean id="dataSourceLog4jdbcAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">  
    4.    <property name="interceptorNames">  
    5.        <list>  
    6.           <value>log4jdbcInterceptor</value>          
    7.        </list>  
    8.    </property>  
    9.    <property name="beanNames">  
    10.        <list>  
    11.           <value>dataSource</value>  
    12.        </list>  
    13.    </property>  
    14. </bean>  

      

     

     

    2.log4j.properties配置:

     

    Java代码  
    1. log4j.logger.jdbc.sqlonly=OFF  
    2. log4j.logger.jdbc.sqltiming=INFO  
    3. log4j.logger.jdbc.audit=OFF  
    4. log4j.logger.jdbc.resultset=OFF  
    5. log4j.logger.jdbc.connection=OFF  

     

     

    (日志信息如果全部为off,log4jdbc将不会生效,因此对性能没有任何影响)

     

    3.下载slf4j

        log4jdbc需要依赖slf4j日志框架. http://www.slf4j.org/

     

    三.扩展说明

     

    DataSourceSpyInterceptor为我自己扩展的一个拦截器类,扩展主要是使用AOP的方式,因为log4jdbc原来的方式不适合我的项目.具体源码为:

     

    Java代码  
    1. import org.aopalliance.intercept.MethodInterceptor;  
    2. import org.aopalliance.intercept.MethodInvocation;  
    3.   
    4. public class DataSourceSpyInterceptor implements MethodInterceptor {  
    5.   
    6.     private RdbmsSpecifics rdbmsSpecifics = null;  
    7.       
    8.     private RdbmsSpecifics getRdbmsSpecifics(Connection conn) {  
    9.         if(rdbmsSpecifics == null) {  
    10.             rdbmsSpecifics = DriverSpy.getRdbmsSpecifics(conn);  
    11.         }  
    12.         return rdbmsSpecifics;  
    13.     }  
    14.       
    15.     public Object invoke(MethodInvocation invocation) throws Throwable {  
    16.         Object result = invocation.proceed();  
    17.         if(SpyLogFactory.getSpyLogDelegator().isJdbcLoggingEnabled()) {  
    18.             if(result instanceof Connection) {  
    19.                 Connection conn = (Connection)result;  
    20.                 return new ConnectionSpy(conn,getRdbmsSpecifics(conn));  
    21.             }  
    22.         }  
    23.         return result;  
    24.     }  
    25.   
    26. }  

       

     

    四.相关下载:

     jar :slf4j-log4j12-1.7.1.jar slf4j-api-1.7.1.jar log4jdbc3-1.2.1.jar log4jdbc-remix-0.2.7.jar

    然后在下载 log4jdbc-remix-0.2.7.jar源码

    借用hibernate sql格式化工具类,把sql格式化一把。这样可以把hibernate.show_sql设置为false。 
    修改Slf4jSpyLogDelegator类 
    out.append(sql); 
    out.append(" {executed in "); 
    out.append(execTime); 
    out.append(" msec}"); 
    BasicFormatterImpl format = new BasicFormatterImpl(); 
    return format.format(out.toString());

    log4jdbc:   http://code.google.com/p/log4jdbc/

    另外一个对log4jdbc的扩展:  http://code.google.com/p/log4jdbc-remix/

    转载于:https://www.cnblogs.com/eggbucket/archive/2012/11/15/2771572.html

    展开全文
  • 22:09:15.617 DEBUG log4jdbc.debug- [SQL-CONFIG]:... log4jdbc initializing ...22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]: log4jdbc.properties not found on classpath22:09:15.618 DEBUG log4jdbc....

    22:09:15.617 DEBUG log4jdbc.debug- [SQL-CONFIG]:... log4jdbc initializing ...

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]: log4jdbc.properties not found on classpath

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.debug.stack.prefix is not defined

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.sqltiming.warn.threshold is not defined

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.sqltiming.error.threshold is not defined

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.booleanastruefalse is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.maxlinelength is not defined (using default of 200)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.fulldebugstacktrace is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.statement.warn is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.select is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.insert is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.update is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.delete is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.create is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.addsemicolon is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.auto.load.popular.drivers is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.trim.sql is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.trim.sql.extrablanklines is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.suppress.generated.keys.exception is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.drivers is not defined

    22:09:15.626 DEBUG log4jdbc.debug- [SQL-CONFIG]: FOUND DRIVER com.mysql.jdbc.Driver

    22:09:15.628 DEBUG log4jdbc.debug- [SQL-CONFIG]:... log4jdbc initialized! ...

    22:09:15.785 INFO jdbc.connection- [SQL]:(connection:1,3aa82b22). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:15.785 DEBUG jdbc.connection- [SQL]:open connections: 1 (1)

    22:09:15.785 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:15.798 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.799 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.prepareStatement(drop table if exists test_curd) returned net.sf.log4jdbc.PreparedStatementSpy@7cd569b5 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.800 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@2b64ff3b org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:15.800 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:1,3aa82b22). drop table if exists test_curd

    22:09:15.990 DEBUG jdbc.sqltiming- [SQL]:(connection:1,3aa82b22){drop table if exists test_curd }USE:190ms

    22:09:15.991 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.executeUpdate() returned 0 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:15.992 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    22:09:15.993 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.993 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.prepareStatement(CREATE TABLE `test_curd` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_date` datetime DEFAULT NULL, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;) returned net.sf.log4jdbc.PreparedStatementSpy@7d380be8 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.994 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@6a95ec91 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:15.994 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:1,3aa82b22). CREATE TABLE `test_curd` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_date` datetime DEFAULT NULL, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

    22:09:16.741 DEBUG jdbc.sqltiming- [SQL]:(connection:1,3aa82b22){CREATE TABLE `test_curd` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_date` datetime DEFAULT NULL, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; }USE:747ms

    22:09:16.742 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.executeUpdate() returned 0 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:16.742 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    清理表

    22:09:16.743 INFO jdbc.connection- [SQL]:(connection:1,3aa82b22). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.743 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:16.743 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.758 INFO jdbc.connection- [SQL]:(connection:2,6e9637fe). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:16.758 DEBUG jdbc.connection- [SQL]:open connections: 2 (1)

    22:09:16.758 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:16.761 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.761 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). Connection.prepareStatement(insert into test_curd(name,create_date) values(?,?), 1) returned net.sf.log4jdbc.PreparedStatementSpy@7deb27fa org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.762 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@598dceab org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:16.762 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.setObject(1, 测试中文) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.775 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.setObject(2, Sat Apr 29 22:09:16 CST 2017) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.775 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606) (connection:2,6e9637fe). insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16')

    22:09:16.856 DEBUG jdbc.sqltiming- [SQL]:(connection:2,6e9637fe){insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16') }USE:80ms

    22:09:16.856 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.executeUpdate() returned 1 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606)

    22:09:16.871 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.872 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.new ResultSet returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.872 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getGeneratedKeys() returned net.sf.log4jdbc.ResultSetSpy@2e28dfb2 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.873 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.873 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.next() returned true org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.876 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.877 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.getMetaData() returned com.mysql.jdbc.ResultSetMetaData@3c1a42fa - Field level information:

    com.mysql.jdbc.Field@602349e9[catalog=null,tableName=,originalTableName=null,columnName=GENERATED_KEY,originalColumnName=null,mysqlType=-1( Unknown MySQL Type # -1),flags=, charsetIndex=0, charsetName=UTF8] org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.878 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.878 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.getObject(1) returned 1 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.879 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    insertTest: {GENERATED_KEY=1}

    insertTest: null

    22:09:16.881 INFO jdbc.connection- [SQL]:(connection:2,6e9637fe). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.881 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:16.882 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.905 INFO jdbc.connection- [SQL]:(connection:3,454d427a). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:16.905 DEBUG jdbc.connection- [SQL]:open connections: 3 (1)

    22:09:16.905 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). Connection.prepareStatement(insert into test_curd(name,create_date) values(?,?), 1) returned net.sf.log4jdbc.PreparedStatementSpy@79e4de3d org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@20bab550 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.setObject(1, 测试中文) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.907 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.setObject(2, Sat Apr 29 22:09:16 CST 2017) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.907 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606) (connection:3,454d427a). insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16')

    22:09:16.986 DEBUG jdbc.sqltiming- [SQL]:(connection:3,454d427a){insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16') }USE:79ms

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.executeUpdate() returned 1 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606)

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.987 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.new ResultSet returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getGeneratedKeys() returned net.sf.log4jdbc.ResultSetSpy@65006fed org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.988 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.next() returned true org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.988 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.getMetaData() returned com.mysql.jdbc.ResultSetMetaData@7fb46468 - Field level information:

    com.mysql.jdbc.Field@1c2c2958[catalog=null,tableName=,originalTableName=null,columnName=GENERATED_KEY,originalColumnName=null,mysqlType=-1( Unknown MySQL Type # -1),flags=, charsetIndex=0, charsetName=UTF8] org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.988 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.getObject(1) returned 2 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    insertTest: {GENERATED_KEY=2}

    insertTest: null

    22:09:16.988 INFO jdbc.connection- [SQL]:(connection:3,454d427a). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.988 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.998 INFO jdbc.connection- [SQL]:(connection:4,3bf06804). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:16.998 DEBUG jdbc.connection- [SQL]:open connections: 4 (1)

    22:09:16.998 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:16.998 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). Connection.prepareStatement(select * from test_curd where id>?) returned net.sf.log4jdbc.PreparedStatementSpy@201d324c org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@5cd12c0c org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.setObject(1, 1) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.999 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347) (connection:4,3bf06804). select * from test_curd where id>1

    22:09:16.999 DEBUG jdbc.sqltiming- [SQL]:(connection:4,3bf06804){select * from test_curd where id>1 }USE:0ms

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347)

    22:09:16.999 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.new ResultSet returned org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.executeQuery() returned net.sf.log4jdbc.ResultSetSpy@6322ad40 org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.handlers.ArrayHandler.handle(ArrayHandler.java:83)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.next() returned true org.apache.commons.dbutils.handlers.ArrayHandler.handle(ArrayHandler.java:83)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:99)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getMetaData() returned com.mysql.jdbc.ResultSetMetaData@799c7798 - Field level information:

    com.mysql.jdbc.Field@f6fda88[catalog=test,tableName=test_curd,originalTableName=test_curd,columnName=id,originalColumnName=id,mysqlType=3(FIELD_TYPE_LONG),flags= AUTO_INCREMENT PRIMARY_KEY, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@78741ea2[catalog=test,tableName=test_curd,originalTableName=test_curd,columnName=create_date,originalColumnName=create_date,mysqlType=12(FIELD_TYPE_DATETIME),flags= BINARY, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@f875b76[catalog=test,tableName=test_curd,originalTableName=test_curd,columnName=name,originalColumnName=name,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8] org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:99)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getObject(1) returned 2 org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getObject(2) returned 2017-04-29 22:09:16.0 org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.001 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getObject(3) returned 测试中文 org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.001 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.DbUtils.close(DbUtils.java:72)

    22:09:17.001 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:72)

    22:09:17.001 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    selectTest: [2, 2017-04-29 22:09:16.0, 测试中文]

    22:09:17.001 INFO jdbc.connection- [SQL]:(connection:4,3bf06804). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.001 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:17.001 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.011 INFO jdbc.connection- [SQL]:(connection:5,6f9bc97). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:17.011 DEBUG jdbc.connection- [SQL]:open connections: 5 (1)

    22:09:17.011 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:17.011 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.011 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). Connection.prepareStatement(update test_curd set name = ? where id >= ?) returned net.sf.log4jdbc.PreparedStatementSpy@3cf9a477 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.012 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@299c9fe7 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:17.012 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.setObject(1, 更新后的值) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:17.012 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.setObject(2, 0) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:17.012 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:5,6f9bc97). update test_curd set name = '更新后的值' where id >= 0

    22:09:17.120 DEBUG jdbc.sqltiming- [SQL]:(connection:5,6f9bc97){update test_curd set name = '更新后的值' where id >= 0 }USE:108ms

    22:09:17.120 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.executeUpdate() returned 2 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:17.121 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    成功更新2条数据!

    22:09:17.122 INFO jdbc.connection- [SQL]:(connection:5,6f9bc97). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.122 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:17.122 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.163 INFO jdbc.connection- [SQL]:(connection:6,85132f5). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:17.163 DEBUG jdbc.connection- [SQL]:open connections: 6 (1)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). Connection.prepareStatement(DELETE from test_curd WHERE id = ?) returned net.sf.log4jdbc.PreparedStatementSpy@23e28c99 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@6e7ca336 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:17.165 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.setObject(1, 0) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:17.165 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:6,85132f5). DELETE from test_curd WHERE id = 0

    22:09:17.166 DEBUG jdbc.sqltiming- [SQL]:(connection:6,85132f5){DELETE from test_curd WHERE id = 0 }USE:0ms

    22:09:17.166 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.executeUpdate() returned 0 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:17.166 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    删除成功0条数据!

    22:09:17.167 INFO jdbc.connection- [SQL]:(connection:6,85132f5). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.167 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:17.167 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    展开全文
  • 像 hibernate, mybatis 都是不打印真正执行的sql的,所以借助 log4jdbc 打印sql以及统计执行时间是非常方便的。配置log4jdbc 有很多种方法,比如通过spring的拦截器。最简单的方法就是在jdbc.url 连接参数加上log4...

    像 hibernate, mybatis 都是不打印真正执行的sql的,所以借助 log4jdbc 打印sql以及统计执行时间是非常方便的。

    配置log4jdbc 有很多种方法,比如通过spring的拦截器。最简单的方法就是在jdbc.url 连接参数加上log4jdbc,然后引入相应的log4jdbc包即可。

    # 修改前

    spring.datasource.driver-class-name=com.mysql.jdbc.Driver

    spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8

    # 修改后

    spring.datasource.driver-class-name=net.sf.log4jdbc.DriverSpy

    spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8

    48304ba5e6f9fe08f3fa1abda7d326ab.png

    COMMENT 原连接参数:

    jdbc.url=jdbc:mysql://127.0.0.1:3306/theme?characterEncoding=utf-8

    COMMENT 加入log4jdbc后的连接参数:

    jdbc.url=jdbc:log4jdbc:mysql://127.0.0.1:3306/theme?characterEncoding=utf-8

    48304ba5e6f9fe08f3fa1abda7d326ab.png

    引入jar包

    48304ba5e6f9fe08f3fa1abda7d326ab.png

    com.googlecode.log4jdbc

    log4jdbc

    1.2

    runtime

    48304ba5e6f9fe08f3fa1abda7d326ab.png

    我用logback,所以还要引入logback 和 slf4j-api包。

    因为log4jdbc 默认输出很多日志,所以需要配置,可以通过新建 log4jdbc.properties 配置,也可以通过logback.xml文件里配置, 用log4j的则是通过log4j.properties 或log4j.xml配置。

    48304ba5e6f9fe08f3fa1abda7d326ab.png

    48304ba5e6f9fe08f3fa1abda7d326ab.png

    展开全文
  • 22:09:15.617 DEBUG log4jdbc.debug- [SQL-CONFIG]:... log4jdbc initializing ...22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]: log4jdbc.properties not found on classpath22:09:15.618 DEBUG log4jdbc....

    22:09:15.617 DEBUG log4jdbc.debug- [SQL-CONFIG]:... log4jdbc initializing ...

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]: log4jdbc.properties not found on classpath

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.debug.stack.prefix is not defined

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.sqltiming.warn.threshold is not defined

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.sqltiming.error.threshold is not defined

    22:09:15.618 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.booleanastruefalse is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.maxlinelength is not defined (using default of 200)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.fulldebugstacktrace is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.statement.warn is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.select is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.insert is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.update is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.delete is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.create is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.dump.sql.addsemicolon is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.auto.load.popular.drivers is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.trim.sql is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.trim.sql.extrablanklines is not defined (using default value true)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.suppress.generated.keys.exception is not defined (using default value false)

    22:09:15.619 DEBUG log4jdbc.debug- [SQL-CONFIG]:log4jdbc.drivers is not defined

    22:09:15.626 DEBUG log4jdbc.debug- [SQL-CONFIG]: FOUND DRIVER com.mysql.jdbc.Driver

    22:09:15.628 DEBUG log4jdbc.debug- [SQL-CONFIG]:... log4jdbc initialized! ...

    22:09:15.785 INFO jdbc.connection- [SQL]:(connection:1,3aa82b22). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:15.785 DEBUG jdbc.connection- [SQL]:open connections: 1 (1)

    22:09:15.785 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:15.798 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.799 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.prepareStatement(drop table if exists test_curd) returned net.sf.log4jdbc.PreparedStatementSpy@7cd569b5 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.800 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@2b64ff3b org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:15.800 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:1,3aa82b22). drop table if exists test_curd

    22:09:15.990 DEBUG jdbc.sqltiming- [SQL]:(connection:1,3aa82b22){drop table if exists test_curd }USE:190ms

    22:09:15.991 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.executeUpdate() returned 0 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:15.992 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    22:09:15.993 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.993 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.prepareStatement(CREATE TABLE `test_curd` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_date` datetime DEFAULT NULL, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;) returned net.sf.log4jdbc.PreparedStatementSpy@7d380be8 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:15.994 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@6a95ec91 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:15.994 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:1,3aa82b22). CREATE TABLE `test_curd` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_date` datetime DEFAULT NULL, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

    22:09:16.741 DEBUG jdbc.sqltiming- [SQL]:(connection:1,3aa82b22){CREATE TABLE `test_curd` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_date` datetime DEFAULT NULL, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; }USE:747ms

    22:09:16.742 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.executeUpdate() returned 0 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:16.742 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    清理表

    22:09:16.743 INFO jdbc.connection- [SQL]:(connection:1,3aa82b22). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.743 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:16.743 DEBUG jdbc.audit- [SQL]:(connection:1,3aa82b22). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.758 INFO jdbc.connection- [SQL]:(connection:2,6e9637fe). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:16.758 DEBUG jdbc.connection- [SQL]:open connections: 2 (1)

    22:09:16.758 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:16.761 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.761 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). Connection.prepareStatement(insert into test_curd(name,create_date) values(?,?), 1) returned net.sf.log4jdbc.PreparedStatementSpy@7deb27fa org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.762 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@598dceab org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:16.762 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.setObject(1, 测试中文) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.775 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.setObject(2, Sat Apr 29 22:09:16 CST 2017) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.775 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606) (connection:2,6e9637fe). insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16')

    22:09:16.856 DEBUG jdbc.sqltiming- [SQL]:(connection:2,6e9637fe){insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16') }USE:80ms

    22:09:16.856 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.executeUpdate() returned 1 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606)

    22:09:16.871 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.872 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.new ResultSet returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.872 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getGeneratedKeys() returned net.sf.log4jdbc.ResultSetSpy@2e28dfb2 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.873 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.873 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.next() returned true org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.876 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.877 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.getMetaData() returned com.mysql.jdbc.ResultSetMetaData@3c1a42fa - Field level information:

    com.mysql.jdbc.Field@602349e9[catalog=null,tableName=,originalTableName=null,columnName=GENERATED_KEY,originalColumnName=null,mysqlType=-1( Unknown MySQL Type # -1),flags=, charsetIndex=0, charsetName=UTF8] org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.878 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@5cfc2617 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.878 DEBUG jdbc.resultset- [SQL]:(connection:2,5cfc2617). ResultSet.getObject(1) returned 1 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.879 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    insertTest: {GENERATED_KEY=1}

    insertTest: null

    22:09:16.881 INFO jdbc.connection- [SQL]:(connection:2,6e9637fe). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.881 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:16.882 DEBUG jdbc.audit- [SQL]:(connection:2,6e9637fe). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.905 INFO jdbc.connection- [SQL]:(connection:3,454d427a). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:16.905 DEBUG jdbc.connection- [SQL]:open connections: 3 (1)

    22:09:16.905 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). Connection.prepareStatement(insert into test_curd(name,create_date) values(?,?), 1) returned net.sf.log4jdbc.PreparedStatementSpy@79e4de3d org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:604)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@20bab550 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:16.906 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.setObject(1, 测试中文) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.907 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.setObject(2, Sat Apr 29 22:09:16 CST 2017) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.907 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606) (connection:3,454d427a). insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16')

    22:09:16.986 DEBUG jdbc.sqltiming- [SQL]:(connection:3,454d427a){insert into test_curd(name,create_date) values('测试中文','2017-04-29 22:09:16') }USE:79ms

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.executeUpdate() returned 1 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:606)

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.987 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.new ResultSet returned org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getGeneratedKeys() returned net.sf.log4jdbc.ResultSetSpy@65006fed org.apache.commons.dbutils.QueryRunner.insert(QueryRunner.java:607)

    22:09:16.987 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.988 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.next() returned true org.apache.commons.dbutils.handlers.MapHandler.handle(MapHandler.java:73)

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.988 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.getMetaData() returned com.mysql.jdbc.ResultSetMetaData@7fb46468 - Field level information:

    com.mysql.jdbc.Field@1c2c2958[catalog=null,tableName=,originalTableName=null,columnName=GENERATED_KEY,originalColumnName=null,mysqlType=-1( Unknown MySQL Type # -1),flags=, charsetIndex=0, charsetName=UTF8] org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:161)

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@3206ee33 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.988 DEBUG jdbc.resultset- [SQL]:(connection:3,3206ee33). ResultSet.getObject(1) returned 2 org.apache.commons.dbutils.BasicRowProcessor.toMap(BasicRowProcessor.java:169)

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    insertTest: {GENERATED_KEY=2}

    insertTest: null

    22:09:16.988 INFO jdbc.connection- [SQL]:(connection:3,454d427a). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.988 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:16.988 DEBUG jdbc.audit- [SQL]:(connection:3,454d427a). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:16.998 INFO jdbc.connection- [SQL]:(connection:4,3bf06804). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:16.998 DEBUG jdbc.connection- [SQL]:open connections: 4 (1)

    22:09:16.998 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:16.998 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). Connection.prepareStatement(select * from test_curd where id>?) returned net.sf.log4jdbc.PreparedStatementSpy@201d324c org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@5cd12c0c org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.setObject(1, 1) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:16.999 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347) (connection:4,3bf06804). select * from test_curd where id>1

    22:09:16.999 DEBUG jdbc.sqltiming- [SQL]:(connection:4,3bf06804){select * from test_curd where id>1 }USE:0ms

    22:09:16.999 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347)

    22:09:16.999 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.new ResultSet returned org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.executeQuery() returned net.sf.log4jdbc.ResultSetSpy@6322ad40 org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:347)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.handlers.ArrayHandler.handle(ArrayHandler.java:83)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.next() returned true org.apache.commons.dbutils.handlers.ArrayHandler.handle(ArrayHandler.java:83)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:99)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getMetaData() returned com.mysql.jdbc.ResultSetMetaData@799c7798 - Field level information:

    com.mysql.jdbc.Field@f6fda88[catalog=test,tableName=test_curd,originalTableName=test_curd,columnName=id,originalColumnName=id,mysqlType=3(FIELD_TYPE_LONG),flags= AUTO_INCREMENT PRIMARY_KEY, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@78741ea2[catalog=test,tableName=test_curd,originalTableName=test_curd,columnName=create_date,originalColumnName=create_date,mysqlType=12(FIELD_TYPE_DATETIME),flags= BINARY, charsetIndex=63, charsetName=US-ASCII]

    com.mysql.jdbc.Field@f875b76[catalog=test,tableName=test_curd,originalTableName=test_curd,columnName=name,originalColumnName=name,mysqlType=253(FIELD_TYPE_VAR_STRING),flags=, charsetIndex=33, charsetName=UTF-8] org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:99)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getObject(1) returned 2 org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getObject(2) returned 2017-04-29 22:09:16.0 org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.000 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.001 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.getObject(3) returned 测试中文 org.apache.commons.dbutils.BasicRowProcessor.toArray(BasicRowProcessor.java:104)

    22:09:17.001 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.getConnection() returned net.sf.log4jdbc.ConnectionSpy@28a2f76f org.apache.commons.dbutils.DbUtils.close(DbUtils.java:72)

    22:09:17.001 DEBUG jdbc.resultset- [SQL]:(connection:4,28a2f76f). ResultSet.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:72)

    22:09:17.001 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    selectTest: [2, 2017-04-29 22:09:16.0, 测试中文]

    22:09:17.001 INFO jdbc.connection- [SQL]:(connection:4,3bf06804). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.001 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:17.001 DEBUG jdbc.audit- [SQL]:(connection:4,3bf06804). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.011 INFO jdbc.connection- [SQL]:(connection:5,6f9bc97). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:17.011 DEBUG jdbc.connection- [SQL]:open connections: 5 (1)

    22:09:17.011 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:17.011 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.011 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). Connection.prepareStatement(update test_curd set name = ? where id >= ?) returned net.sf.log4jdbc.PreparedStatementSpy@3cf9a477 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.012 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@299c9fe7 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:17.012 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.setObject(1, 更新后的值) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:17.012 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.setObject(2, 0) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:17.012 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:5,6f9bc97). update test_curd set name = '更新后的值' where id >= 0

    22:09:17.120 DEBUG jdbc.sqltiming- [SQL]:(connection:5,6f9bc97){update test_curd set name = '更新后的值' where id >= 0 }USE:108ms

    22:09:17.120 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.executeUpdate() returned 2 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:17.121 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    成功更新2条数据!

    22:09:17.122 INFO jdbc.connection- [SQL]:(connection:5,6f9bc97). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.122 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:17.122 DEBUG jdbc.audit- [SQL]:(connection:5,6f9bc97). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.163 INFO jdbc.connection- [SQL]:(connection:6,85132f5). Connection opened java.sql.DriverManager.getConnection(null:-1)

    22:09:17.163 DEBUG jdbc.connection- [SQL]:open connections: 6 (1)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). Connection.new Connection returned java.sql.DriverManager.getConnection(null:-1)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.new PreparedStatement returned org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). Connection.prepareStatement(DELETE from test_curd WHERE id = ?) returned net.sf.log4jdbc.PreparedStatementSpy@23e28c99 org.apache.commons.dbutils.AbstractQueryRunner.prepareStatement(AbstractQueryRunner.java:154)

    22:09:17.164 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.getParameterMetaData() returned com.mysql.jdbc.MysqlParameterMetadata@6e7ca336 org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:225)

    22:09:17.165 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.setObject(1, 0) returned org.apache.commons.dbutils.AbstractQueryRunner.fillStatement(AbstractQueryRunner.java:242)

    22:09:17.165 DEBUG jdbc.sqlonly- [SQL]: org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488) (connection:6,85132f5). DELETE from test_curd WHERE id = 0

    22:09:17.166 DEBUG jdbc.sqltiming- [SQL]:(connection:6,85132f5){DELETE from test_curd WHERE id = 0 }USE:0ms

    22:09:17.166 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.executeUpdate() returned 0 org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:488)

    22:09:17.166 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). PreparedStatement.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:84)

    删除成功0条数据!

    22:09:17.167 INFO jdbc.connection- [SQL]:(connection:6,85132f5). Connection closed org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    22:09:17.167 DEBUG jdbc.connection- [SQL]:open connections: none

    22:09:17.167 DEBUG jdbc.audit- [SQL]:(connection:6,85132f5). Connection.close() returned org.apache.commons.dbutils.DbUtils.close(DbUtils.java:60)

    展开全文
  • 像 hibernate, mybatis 都是不打印真正执行的sql的,所以借助 log4jdbc 打印sql以及统计执行时间是非常方便的。配置log4jdbc 有很多种方法,比如通过spring的拦截器。最简单的方法就是在jdbc.url 连接参数加上log4...
  • log4jdbc

    2012-08-10 09:42:15
    log4jdbc可以和sl4j 很好的整合 并输出日志可以捕获程序最终调用jdbc时的一些状态可以获取完整的sql语句,包括注入?的参数值 sql语句可以直接运行可以获取sql语句的执行耗时可以获取jdbc获取结果集时的详细信息过程...
  • log4jdbc官网地址当前最新版本是1.2, 支持JDBC3, JDBC4log4jdbc是在jdbc层的一个日志框架,可以将占位符与参数全部合并在一起显示,方便直接拷贝sql在数据库客户端运行未使用log4jdbc记录的SQL:select count(*) from...
  • jdbc:log4jdbc 当我们开发任何应用程序,完成它或结束其任何模块时,我们都会开始优化过程。 大多数应用程序都包含数据库访问权限,如果您使用的是ORM ,则可能会使用hibernate 。 优化Hibernate持久层,要求准备...
  • log4jdbc 可以将占位符与参数全部合并在一起显示,方便直接拷贝sql在PLSQL Developer等客户端直接执行,加快调试速度. 记录执行的sql及其耗时等.1.测试代码package com.mtea.demo.test;import java.sql.Connection;...
  • 使用log4jdbc在不改变原有代码的情况下,就可以收集执行的SQL文和JDBC执行情况。平时开发使用的ibatis,hibernate,spring jdbc的sql日志信息,有一点个缺点是占位符与参数是分开打印的,如果想要拷贝sql至PLSQL ...
  • 现在各种持久层框架如:hibernate,springdata jpa,mybatis对使用了占位符的sql输出是没有显示完整的sql语句的,所以如果想获取到完整的sql,除了在db层做配置外,也有单独在jdbc层做此功能的项目如:log4jdbc项目...
  • log4jdbc-log4j2,就不多说了,不了解的可以谷歌,附上log4jdbc-log4j2的官方链接:https://code.google.com/p/log4jdbc-log4j2/ ,上面有非常详细的介绍。简单的贴下配置文件,其他的见附件:database.properties:#...
  • Log4jdbc Spring Boot Starter Log4jdbc Spring Boot Starter有助于在Spring Boot项目中快速方便地使用 。 Log4jdbc特别方便,因为它可以记录准备运行SQL。 而不是用'?'记录SQL 在需要插入参数值的地方(例如,...
  • 下载log4jdbc4-1.2.jar,slf4j-api-1.7.5.jar, slf4j-log4j12-1.7.5.jar 三个jar包。2.修改JDBC配置文件class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">driverClassName修改为...
  • 在开发过程中,常常需要验证sql语句,但是spring-boot-starter-data-jpa只支持输出sql不会输出参数,为了方便,集成log4jdbc。一、引入依赖com.googlecode.log4jdbclog4jdbc二、数据库配置因为要使用log4jdbc作为...
  • log4jdbc.rar

    2020-08-06 08:58:11
    log4jdbc所需jar包下载,包括(log4jdbc-1.2.jar以及依赖的相关Jar包log4j-1.2.16/17.jar、slf4j-api-1.6.0/4.jar、slf4j-api-1.7.2.jar、slf4j-log4j12-1.6.1/4.jar、slf4j-log4j12-1.7.1.jar)
  • Log4JdbcFonctionnalités généralesCet outil est un proxy JDBC qui permet d'intercepter les appels au driver jdbc.Compatible à partir de la version Java 3.Divisé en 2 parties, la partie ...
  • log4jdbc mysql jdbc_log4jdbc

    2021-01-27 06:44:32
    private Driver getUnderlyingDriver(String url)throws SQLException{//注意看这里if (url.startsWith("jdbc:log4")){url = url.substring(9);//这里会把所有驱动遍历一次,并确定实际驱动Enumeration e = ...
  • log4jdbc 使用

    2019-08-20 08:19:54
    像 hibernate, mybatis 都是不打印真正执行的sql的,所以借助 log4jdbc 打印sql以及统计执行时间是非常方便的。 配置log4jdbc 有很多种方法,比如通过spring的拦截器。最简单的方法就是在jdbc.url 连接参数加上log...
  • log4jdbc使用

    2019-07-23 15:41:53
    1、下载log4jdbc的jar包log4jdbc-1.2.jar以及依赖的相关Jar包log4j-1.2.17.jar、slf4j-api-1.6.0.jar、slf4j-log4j12-1.7.7.jar,其中maven依赖如下,特别注意,com.googlecode.log4jdbc,这个包才有DriverSpy类的...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,120
精华内容 1,248
关键字:

log4jdbc