- 浏览: 1234225 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (399)
- 心情故事 (12)
- java (115)
- linux (55)
- 关系型数据库 (35)
- struts,jsf,spring (11)
- jdbc,hibernate,ibatis (11)
- jsp,jstl,c:tag,标签库 (2)
- ejb,webservice (1)
- tomcat,jboss,jetty,weblogic,websphere (15)
- java网络编程 (6)
- java线程 (0)
- js,jquery,json,xml,dom,html.regex (25)
- 设计模式 (6)
- BUG记录 (2)
- ant (2)
- jsp,servlet (4)
- swing (6)
- lucene+nutch (6)
- log4j (2)
- windows doc (2)
- ruby (1)
- ruby on rails (3)
- 操作系统网络 (18)
- apache 错误 (1)
- tomcat (10)
- jboss (9)
- jetty (9)
- weblogic (9)
- websphere (10)
- apache (2)
- AIX的iostat命令查看系统磁盘的使用情况 (1)
- oracle 统计一个表格有多少列 (1)
- Exception in thread "main" java.security.KeyStoreException: Windows-MY not found (1)
- jsp (1)
- jstl (1)
- c:tag (1)
- 标签库 (1)
- struts (1)
- jsf (1)
- spring (2)
- oracle,sqlplus (2)
- sqlplus (2)
- show errors (1)
- proc (1)
- function (1)
- ORA-06544: PL/SQL: internal error (1)
- arguments: [55916] (1)
- [] (7)
- 终端身份实施文档 (1)
- 重装系统之后飞鸽传书只能看到自己 (1)
- vsftp "上传 553 Could not create file" (1)
- startWebLogic.sh启动失败,提示Error initializing Embedded LDAP Server (1)
- java agent 注册为 windows 服务 (1)
- centos (1)
- svn (1)
- apr (1)
- apr-util (1)
- activemq (2)
- oracle (5)
- mysql (3)
- nosql (3)
- NSIS (1)
- windows wmic (1)
- c 指针 (1)
- c c++ (0)
- jmeter (0)
- 性能测试 (0)
- linux,备份 (2)
- C++ ,Virtual (1)
- windows dos (1)
- android (2)
- 大数据,云计算 (1)
- JVM垃圾收集 (1)
- jdbc (2)
- invoke (1)
- hibernate (1)
- ibatis (1)
- 个人开源项目源码收藏 (1)
- 批处理 (1)
- Mongodb mapreduce (8)
- kettle (1)
- Mongodb capped (1)
- mongodb gridfs (1)
- Mongodb 入门基础知识 (1)
- mongodb (8)
- hadoop2.5.1 (1)
- hadoop (4)
- eclipse (1)
- hdfs fs (1)
- elipse hadoop plugin (1)
- PHP相关知识 (1)
- js (1)
- jquery (1)
- json (1)
- xml (1)
- dom (1)
- html.regex (1)
- 网络知识 (1)
- nginx (1)
- docker (1)
- 测试 (1)
- nodejs (1)
- iptables (1)
- linux gitlab (1)
最新评论
-
July01:
最近了解到一款StratoIO打印控件,功能如下:1、Html ...
web页面调用window.print()函数实现打印的功能 -
hxdtech:
非常感谢!
我在学习ibatis时的培训ppt -
zmwxiaoming:
what 能连数据库不错
SOLR的学习整理 -
springdata_springmvc:
java程序语言学习教程 地址http://www.zuida ...
java获取当前操作系统的信息 -
huanzei:
整理的不错,
oracle lpad函数
准备用swing做一个拨号程序,和数据库打交道的地方比较多,所以考虑用ibatis来和数据库交互,在搭框架的时候,调式程序时 sql语句没有被打印出来,所以决定用log4j打印出来,以方便调式。
我使用的是netbeans6.0.1,在工程的根目录新建一个log4j.properties的文件,然后在里面加上配置:代码如下:
ibatis2.3 --log4j 写道
log4j.rootLogger=info,stdout
log4j.debug=true
#ibatis log configure
log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.debug=true
#ibatis log configure
log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=DEBUG
注意这句话:
log4j.rootLogger=info,stdout 写道
log4j.rootLogger=info,stdout
假如不加上这句话的话,那么log4j不会输入sql语句,但是会输入一些null,测试时控制台打印如下:
写道
log4j: Could not find root logger information. Is this OK?
log4j: Parsing for [com.ibatis.common.jdbc.SimpleDataSource] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.SimpleDataSource set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.SimpleDataSource=[null]
log4j: Parsing for [java.sql.Connection] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Connection set to DEBUG
log4j: Handling log4j.additivity.java.sql.Connection=[null]
log4j: Parsing for [com.ibatis] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis set to DEBUG
log4j: Handling log4j.additivity.com.ibatis=[null ]
log4j: Parsing for [com.ibatis.common.jdbc.ScriptRunner] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.ScriptRunner set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.ScriptRunner=[null ]
log4j: Parsing for [com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=[null ]
log4j: Parsing for [java.sql.Statement] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Statement set to DEBUG
log4j: Handling log4j.additivity.java.sql.Statement=[null ]
log4j: Parsing for [java.sql.PreparedStatement] with value=[DEBUG].
log4j: Level token is [DEBUG].
log4j: Category java.sql.PreparedStatement set to DEBUG
log4j: Handling log4j.additivity.java.sql.PreparedStatement=[null ]
log4j: Finished configuring.
log4j:WARN No appenders could be found for logger (com.ibatis.common.jdbc.SimpleDataSource).
log4j:WARN Please initialize the log4j system properly.
log4j: Parsing for [com.ibatis.common.jdbc.SimpleDataSource] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.SimpleDataSource set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.SimpleDataSource=[null]
log4j: Parsing for [java.sql.Connection] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Connection set to DEBUG
log4j: Handling log4j.additivity.java.sql.Connection=[null]
log4j: Parsing for [com.ibatis] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis set to DEBUG
log4j: Handling log4j.additivity.com.ibatis=[null ]
log4j: Parsing for [com.ibatis.common.jdbc.ScriptRunner] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.ScriptRunner set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.ScriptRunner=[null ]
log4j: Parsing for [com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=[null ]
log4j: Parsing for [java.sql.Statement] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Statement set to DEBUG
log4j: Handling log4j.additivity.java.sql.Statement=[null ]
log4j: Parsing for [java.sql.PreparedStatement] with value=[DEBUG].
log4j: Level token is [DEBUG].
log4j: Category java.sql.PreparedStatement set to DEBUG
log4j: Handling log4j.additivity.java.sql.PreparedStatement=[null ]
log4j: Finished configuring.
log4j:WARN No appenders could be found for logger (com.ibatis.common.jdbc.SimpleDataSource).
log4j:WARN Please initialize the log4j system properly.
只有加上了这句:log4j.rootLogger=info,stdout
控制台才会输入sql语句:
输入 sql 写道
log4j: Parsing for [root] with value=[info,stdout].
log4j: Level token is [info].
log4j: Category root set to INFO
log4j: Parsing appender named "stdout".
log4j: Parsing layout options for "stdout".
log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %5p %c{1}:%L - %m%n].
log4j: End of parsing for "stdout".
log4j: Setting property [target] to [System.out].
log4j: Parsed "stdout" options.
log4j: Parsing for [com.ibatis.common.jdbc.SimpleDataSource] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.SimpleDataSource set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.SimpleDataSource=[null]
log4j: Parsing for [java.sql.Connection] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Connection set to DEBUG
log4j: Handling log4j.additivity.java.sql.Connection=[null]
log4j: Parsing for [com.ibatis] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis set to DEBUG
log4j: Handling log4j.additivity.com.ibatis=[null]
log4j: Parsing for [com.ibatis.common.jdbc.ScriptRunner] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.ScriptRunner set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.ScriptRunner=[null]
log4j: Parsing for [com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=[null]
log4j: Parsing for [java.sql.Statement] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Statement set to DEBUG
log4j: Handling log4j.additivity.java.sql.Statement=[null]
log4j: Parsing for [java.sql.PreparedStatement] with value=[DEBUG].
log4j: Level token is [DEBUG].
log4j: Category java.sql.PreparedStatement set to DEBUG
log4j: Handling log4j.additivity.java.sql.PreparedStatement=[null]
log4j: Finished configuring.
15:05:23,268 DEBUG SimpleDataSource:27 - Created connection 12707029.
15:05:23,331 DEBUG Connection:27 - {conn-100000} Connection
15:05:23,378 DEBUG Connection:27 - {conn-100000} Preparing Statement: select euser_id as userId,eusernamee as username,eusernamec as usernamec,epassword as password,egroup_id as groupId,elevel_id as levelId,earea_id as areaId,eaddr as address,econtact1 as contactOne,econtact2 as contactTwo,email as email from mc$lg_euser where EUSERNAMEC=?
15:05:27,159 DEBUG PreparedStatement:27 - {pstm-100001} Executing Statement: select euser_id as userId,eusernamee as username,eusernamec as usernamec,epassword as password,egroup_id as groupId,elevel_id as levelId,earea_id as areaId,eaddr as address,econtact1 as contactOne,econtact2 as contactTwo,email as email from mc$lg_euser where EUSERNAMEC=?
15:05:27,190 DEBUG PreparedStatement:27 - {pstm-100001} Parameters: [上帝发誓 ]
15:05:27,237 DEBUG PreparedStatement:27 - {pstm-100001} Types: [java.lang.String]
15:05:29,612 DEBUG SimpleDataSource:27 - Returned connection 12707029 to pool.
log4j: Level token is [info].
log4j: Category root set to INFO
log4j: Parsing appender named "stdout".
log4j: Parsing layout options for "stdout".
log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %5p %c{1}:%L - %m%n].
log4j: End of parsing for "stdout".
log4j: Setting property [target] to [System.out].
log4j: Parsed "stdout" options.
log4j: Parsing for [com.ibatis.common.jdbc.SimpleDataSource] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.SimpleDataSource set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.SimpleDataSource=[null]
log4j: Parsing for [java.sql.Connection] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Connection set to DEBUG
log4j: Handling log4j.additivity.java.sql.Connection=[null]
log4j: Parsing for [com.ibatis] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis set to DEBUG
log4j: Handling log4j.additivity.com.ibatis=[null]
log4j: Parsing for [com.ibatis.common.jdbc.ScriptRunner] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.common.jdbc.ScriptRunner set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.common.jdbc.ScriptRunner=[null]
log4j: Parsing for [com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate set to DEBUG
log4j: Handling log4j.additivity.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=[null]
log4j: Parsing for [java.sql.Statement] with value=[debug].
log4j: Level token is [debug].
log4j: Category java.sql.Statement set to DEBUG
log4j: Handling log4j.additivity.java.sql.Statement=[null]
log4j: Parsing for [java.sql.PreparedStatement] with value=[DEBUG].
log4j: Level token is [DEBUG].
log4j: Category java.sql.PreparedStatement set to DEBUG
log4j: Handling log4j.additivity.java.sql.PreparedStatement=[null]
log4j: Finished configuring.
15:05:23,268 DEBUG SimpleDataSource:27 - Created connection 12707029.
15:05:23,331 DEBUG Connection:27 - {conn-100000} Connection
15:05:23,378 DEBUG Connection:27 - {conn-100000} Preparing Statement: select euser_id as userId,eusernamee as username,eusernamec as usernamec,epassword as password,egroup_id as groupId,elevel_id as levelId,earea_id as areaId,eaddr as address,econtact1 as contactOne,econtact2 as contactTwo,email as email from mc$lg_euser where EUSERNAMEC=?
15:05:27,159 DEBUG PreparedStatement:27 - {pstm-100001} Executing Statement: select euser_id as userId,eusernamee as username,eusernamec as usernamec,epassword as password,egroup_id as groupId,elevel_id as levelId,earea_id as areaId,eaddr as address,econtact1 as contactOne,econtact2 as contactTwo,email as email from mc$lg_euser where EUSERNAMEC=?
15:05:27,190 DEBUG PreparedStatement:27 - {pstm-100001} Parameters: [上帝发誓 ]
15:05:27,237 DEBUG PreparedStatement:27 - {pstm-100001} Types: [java.lang.String]
15:05:29,612 DEBUG SimpleDataSource:27 - Returned connection 12707029 to pool.
评论
1 楼
smalltiger1984
2009-05-18
15:05:27,190 DEBUG PreparedStatement:27 - {pstm-100001} Parameters: [上帝发誓 ]
15:05:27,237 DEBUG PreparedStatement:27 - {pstm-100001} Types: [java.lang.String]
15:05:29,612 DEBUG SimpleDataSource:27 - Returned connection 12707029 to pool.
15:05:27,237 DEBUG PreparedStatement:27 - {pstm-100001} Types: [java.lang.String]
15:05:29,612 DEBUG SimpleDataSource:27 - Returned connection 12707029 to pool.
发表评论
-
Swing从一个窗口向另一个窗口传参
2009-05-12 15:06 3647假设有两个JFrame,现在我在第一窗口里面输入一个名字, ... -
Swing控件JSplitPane的使用
2009-05-12 13:54 20131Swing分割窗口控件JSplitPane,用来将窗口分 ... -
Swing控件JList的使用
2009-05-12 11:11 58051JList控件类似于一组单选按钮或复选框,通过点击自身来 ... -
Swing编辑器面板(JEditPane)
2009-05-11 15:49 29691 JEditPane是一款功能 ... -
Swing常用控件使用笔记
2009-05-11 14:59 23161netbeans是开发java左面 ...
相关推荐
WAS上log4j日志不能输出(ibatis)sql语句解决办法[借鉴].pdf
log4j和ibatis配置文档 留在这里,大家可以参考,也可以用来给自己备忘。
在ibatis日志信息中打印SQL语句的方法(个人总结)
WebSphere V5 配置log4j的方法说明和log4j修改后的jar包以及iBATIS输出SQL的log4j.properties
ibatis常用sql语句,简单易懂,方便查询,初学者宝典
ibatis常用的sql语句,很全的一篇文档。。。
iBatis最全的动态SQL语句,你需要的都有,资源在于大家共享
NULL 博文链接:https://javatea.iteye.com/blog/2116542
ibatis16个常用sql语句
这是本人搭建的纯净版SpringMVC+ibatis框架,带有Log4j,测试通过,目前自己的项目就是用这个来写的
ibatis sql 语句的编写 ,包括增删改查,很简单 很实用 ,对初学者是很好的选择
ibatis 开发指南 和 iBATIS-SqlMaps两本图书
ibatis2包和能显示执行的sql语句的ibatis2.jar 能够显示所执行的sql
用Ibatis时,配置sql语句时候 如果直接从sql里面把语句拷出来,玩玩格式不严谨,我写了这个工具来帮助我们格式化sql语句
ibatis sql语句对条件中特殊字符% # 处理
ibatis用xml配置文件配置的使用,基本包括了ibatis遇到的所有问题
SQL Map使用简单的XML配置文件将Java Bean映射成SQL语句,对比其他的数据库持续层和ORM框架(如JDO的实现,Hibernate等),SQL Map最大的优点在于它简单易学。要使用SQL Map,只要熟悉Java Bean,XML和SQL,就能使您...
通过java程序查看ibatis配置文件中的sql语句(注:无法查看变量值)
开发指南 iBATIS SQL Maps Page 3 of 62 Map类型的Result 复杂类型属性(即自定义类型的属性) 避免N+1 Select(1:1) 延迟加载 VS 联合查询(1:1) 复杂类型集合的属性 避免N+1 Select(1:M和M:N) 组合键值或多...