没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > datasource-proxy |
datasource-proxy
|
0 | 0 | 11 |
贡献者 | 讨论 | 代码提交 |
AboutProvide a datasource proxy class to intercept executing queries.
Featuresobtain all executed query & parameter obtain query execuion time obtain total query execution time, num of database call, and num of queries log all of the above obtained information inject custom logic before/after all query execution jdbc query metrics How to use>> sample setup
spring
>> more config samples
programmaticDataSource
DataSource dataSource = (DataSource)((new InitialContext()).lookup("java:comp/env/ref/ds"));
ProxyDataSource proxyDS = new ProxyDataSource();
proxyDS.setDataSource(dataSource);
proxyDS.setListener(new CommonsQueryLoggingListener());
proxyDS.setDataSourceName("MyDataSource");DriverManager
Class.forName("org.hsqldb.jdbcDriver");
Connection realConnection = DriverManager.getConnection("jdbc:hsqldb:mem:aname");
Connection proxyConnection = JdbcProxyFactory.createConnection(realConnection, new CommonsQueryLoggingListener());
>> more config samples
taglib (optional)
- Select
- Update for datasource FOO
- Total Queries
- Num of DB Call
- Total TImeLogging Examplequery executionTime:13, Num:1, Query:{[create table emp ( id integer primary key, name varchar(10) );][]}
Time:10, Num:1, Query:{[insert into emp ( id, name )values (?, ?);][1, foo]}
Time:1, Num:1, Query:{[select this_.id as id0_0_, this_.name as name0_0_, this_.value as value0_0_ from emp this_ where (this_.id=? and this_.name=?)][1,bar]}query statistics metricsDataSource:MyDatasourceA ElapsedTime:13 Call:7 Query:7 (Select:3 Insert:2 Update:1 Delete:0 Other:1)
DataSource:MyDatasourceB ElapsedTime:1 Call:1 Query:1 (Select:1 Insert:0 Update:0 Delete:0 Other:0)Library DependencyNo dependencies to other libraries, everything is optional.
For example, if you use SLF4JQueryLoggingListener, then you need slf4j library.