简体   繁体   English

验证使用JPA运行的c3p0

[英]Verify c3p0 running with JPA

I'm using JPA for my persistence for my project and don't really know anything about hibernate but most tutorials I follow have found to setup connection pooling use c3p0 and hibernate. 我正在使用JPA来保持项目的持久性,并且对休眠状态一无所知,但是我遵循的大多数教程都发现使用c3p0和休眠来设置连接池。

Heres my persistence.xml file 这是我的persistence.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="Cinemango308PU" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>JPA.Ad</class>
    <class>JPA.Photo</class>
    <class>JPA.Theatre</class>
    <class>JPA.Creditcard</class>
    <class>JPA.Moviereview</class>
    <class>JPA.Giftcard</class>
    <class>JPA.Showtime</class>
    <class>JPA.Ticket</class>
    <class>JPA.Favoritetheatres</class>
    <class>JPA.User</class>
    <class>JPA.Actor</class>
    <class>JPA.Movie</class>
    <class>JPA.Theatrerewards</class>
    <class>JPA.Payment</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:5432/cinemango>
      <property name="javax.persistence.jdbc.user" value="xxxx"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.password" value="xxxxxx"/>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>

      <!-- Configuring Connection Pool -->
      <property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />

          <property name="hibernate.c3p0.max_size" value="5" />
          <property name="hibernate.c3p0.min_size" value="0" />
          <property name="hibernate.c3p0.acquire_increment" value="1" />
          <property name="hibernate.c3p0.idle_test_period" value="300" />
          <property name="hibernate.c3p0.max_statements" value="0" />
          <property name="hibernate.c3p0.timeout" value="100" />
    </properties>
  </persistence-unit>
</persistence>

How do i test if the connection pooling is working? 如何测试连接池是否正常工作? I don't see a log displayed to my output 我没有看到日志显示在我的输出中

Please find the logging configuration here http://www.mchange.com/projects/c3p0/#configuring_logging 请在此处找到日志记录配置http://www.mchange.com/projects/c3p0/#configuring_logging

There you can find how to switch on debug to see if pooling happens. 在那里,您可以找到如何打开调试以查看是否发生池化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM