OpenJPA 输出 SQL 日志和使用连接池的方法
2010-06-07 16:17
435 查看
How do I see the SQL that OpenJPA is executing?
OpenJPA provides configurable channel-based logging, as described in the chapter on Logging. The simplest example of enabling verbose logging is by using the following property in your persistence.xml file:<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> <persistence-unit name="example-logging" transaction-type="RESOURCE_LOCAL"> <properties> <property name="openjpa.Log" value="SQL=TRACE"/> </properties> </persistence-unit> </persistence>[/code]
How do I enable connection pooling in OpenJPA?
OpenJPA doesn't include any built-in connection pool, but you can use any third-party connection pool that is configurable via the JDBC DataSource API (which most are). The following persistence.xml example shows how to use OpenJPA with a Apache Derby database and the Apache DBCP connection pool:<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> <persistence-unit name="example-derby" transaction-type="RESOURCE_LOCAL"> <properties> <property name="openjpa.ConnectionProperties" value="DriverClassName=org.apache.derby.jdbc.ClientDriver, Url=jdbc:derby://localhost:1527/database, MaxActive=100, MaxWait=10000, TestOnBorrow=true, Username=user, Password=secret"/> <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/> </properties> </persistence-unit> </persistence>[/code]
See the documentation on Using a Third-Party DataSource for further details.
相关文章推荐
- SQL学习:mysql数据库备份和使用日志恢复+python调用mysql方法(4)
- Python使用logging结合decorator模式实现优化日志输出的方法
- JAVA中使用log4j及slf4j进行日志输出的方法详解
- mybatis拦截器的使用(输出日志或sql语句)
- SpringBoot使用logback输出日志并打印sql信息
- java---使用日志输出信息的方法
- 一对一关联查询时使用relation连贯操作查询后,调用getLastSql()方法输出的sql语句
- 执行动态 sql 并为 输出参数赋值、sp_executesql 使用方法
- 使用SQl方法把多行字符直接转换成相应的表输出
- jboss7.1.1下使用log4j输出mybatis3.2.2的SQL语句问题与解决方法
- excel内一键进行sql查询(使用方法 1.选择’需要进行sql查询区域 包括字段名 2 输入sql语句 3.选择输出数据的单元格)
- EF Core使用SQL调用返回其他类型的查询 ASP.NET Core 2.0 使用NLog实现日志记录 CSS 3D transforms cSharp:use Activator.CreateInstance with an Interface? SqlHelper DBHelper C# Thread.Abort方法真的让线程停止了吗? 注意!你的Thread.Abort方法真
- Jfinal中使用日志框架输出完整sql语句信息(mysql+oracle)
- 使用p6spy新版监控分析sql输出log日志
- Python使用logging结合decorator模式实现优化日志输出的方法
- 执行动态 sql 并为 输出参数赋值、sp_executesql 使用方法
- 使用MyBatis和logBack时在日志中输出sql
- 执行动态 sql 并为 输出参数赋值、sp_executesql 使用方法
- 使用Monitor调试Unity3D Android程序日志输出(非DDMS和ADB)
- Junit单元测试使用log4j输出日志