Openjpa SQL log output and connection pool usage

Source: Internet
Author: User
Document directory
  • How do I see the SQL that openjpa is executing?
How do I see the SQL that openjpa is executing?

Openjpa provides retriable channel-based logging, as described in the chapter on logging. The simplest example of enabling verbose logging is by using the following property in yourPersistence. xmlFile:

<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>
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 accessible via the JDBC datasource API (which most are). The followingPersistence. xmlExample 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>

See the documentation on using a third-party datasource for further details.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.