你好,我有一个Maven应用程序,我在上面使用了Java + jersey + Hibernate。
我已经实现了c3p0。日志上没有显示任何错误,但是当我进行测试时,jdbc并未与其他用户建立另一个连接:
请参阅statistics():
jul 25, 2018 2:10:04 PM org.hibernate.engine.internal.StatisticalLoggingSessionEventListener end
INFO: Session Metrics {
28898 nanoseconds spent acquiring 1 JDBC connections;
665621 nanoseconds spent releasing 1 JDBC connections;
70901 nanoseconds spent preparing 1 JDBC statements;
2902975 nanoseconds spent executing 1 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
Persistence.xml:
<!-- <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/> -->
<property name="hibernate.c3p0.min_size" value="0" /> <!-- 5 -->
<property name="hibernate.c3p0.max_size" value="1" /> <!-- 20 -->
<property name="hibernate.c3p0.timeout" value="20" /> <!-- 3000 -->
<property name="hibernate.c3p0.max_statements" value="20" /> <!-- 50 -->
<property name="hibernate.c3p0.idle_test_period" value="20" /> <!-- 300 -->
我需要知道我是否做错了事。
pom.xml:
<!-- Hibernate c3p0 connection pool -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.2.6.Final</version>
</dependency>
<!-- Hibernate c3p0 connection pool -->