简体   繁体   English

连接池已达到最大大小

[英]Connection pool has reached its maximum size

I have changed my app from java7 to java8 as i wanted to try and use lambda expression on a method. 我已将我的应用程序从java7更改为java8,因为我想尝试在方法上使用lambda表达式。

Afterwards i had to upgrade tomcat7 to tomcat8 as it didnt want to run my webservice anymore. 之后,我不得不将tomcat7升级到tomcat8,因为它不想再运行我的Web服务了。

Now since i changed it to tomcat8, i have a problem with the connection pool :\\ 现在,因为我将其更改为tomcat8,所以连接池出现了问题:\\

What did do so far? 到目前为止做了什么? Searched SO and google but could not find anything related to my problem, beside of C3P0 settings which i am not so experienced yet. 搜索SO和google,但除了C3P0设置(我还没有这样的经验)之外,找不到与我的问题有关的任何内容。

<property name="connection_provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.minPoolSize">5</property>
<property name="c3p0.maxPoolSize">100</property>
<property name="c3p0.acquireIncrement">5</property>
<property name="c3p0.maxStatements">200</property>
<property name="c3p0.timeout">180</property>

Does anyone have an idea for me, or do i have to revert back to java7 as i didnt had any problems yesterday. 有没有人对我有个主意,或者我昨天不得不恢复到java7,因为我昨天没有任何问题。

EDIT: added exception msg 编辑:添加了异常味精

SCHWERWIEGEND: Servlet.service() for servlet [RESTservice] in context with path [] threw exception [org.hibernate.HibernateException: The internal connection pool has reached its maximum size and no connection is currently available!] with root cause org.hibernate.HibernateException: The internal connection pool has reached its maximum size and no connection is currently available!

EDIT 17.08.2016: I recoded the app as suggested in the link, it was not that much to change, only add entitymanager dependency and create a persistence.xml from the existing hibernate.cfg.xml. 编辑17.08.2016:我按照链接中的建议重新编码了该应用程序,更改不多,仅添加了objectmanager依赖项并从现有的hibernate.cfg.xml创建了persistence.xml。

The source needed a few changes in the implementation so far, i already had Annotations and persistence imports and it was not that a difference to the Hibernate Syntax. 到目前为止,源代码需要对实现进行一些更改,我已经具有批注和持久性导入,并且与Hibernate语法没有什么区别。

But did i do it correct? 但是我做对了吗? I created a single JPA instance in this case a EntityManager in the constructor and am using it everywhere, do i still need to close and recreate it everywhere? 在这种情况下,我在构造函数中创建了一个JPA实例EntityManager,并在各处使用它,我是否仍然需要在任何地方关闭并重新创建它?

At least the problem im facing at the moment is this exception which doesnt let me experiment further. 至少目前我面临的问题是这种例外情况,它不能让我做进一步的试验。

javax.persistence.PersistenceException: No Persistence provider for EntityManager named ServicePU

my persistence.xml: 我的persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">

    <persistence-unit name="ServicePU">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.connection.url" value="jdbc:sqlserver://xyz" />
            <property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
            <property name="hibernate.connection.username" value="xyz" />
            <property name="hibernate.connection.password" value="xyz" />
            <property name="hibernate.archive.autodetection" value="class" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hbm2ddl.auto" value="update" />
        </properties>
    </persistence-unit>
</persistence>

I hope the MSSQL driver isnt the problem here :=) 我希望MSSQL驱动程序不是这里的问题:=)

It looks like you are not closing your transactions after each access to the DB. 每次访问数据库后,您似乎都没有关闭事务。 I would recommend using JPA entity manager or my personal preference using spring framework , anyway this link provides and easy example http://www.javawebtutor.com/articles/jpa/jpa-example-using-maven.php 无论如何,我建议使用JPA实体管理器或使用spring框架作为我的个人喜好,无论如何,此链接提供了简单的示例http://www.javawebtutor.com/articles/jpa/jpa-example-using-maven.php

I had this issue on updating Tomcat - it was caused by not explicitly stating the way the public key generation is handled on one of my entity classes (using the @GeneratedValue annotation). 我在更新Tomcat时遇到了这个问题-这是由于未明确说明对我的一个实体类(使用@GeneratedValue批注)处理公钥生成的方式而引起的。

I also get the same exception if using GenerationType.AUTO instead of IDENTITY (which is used for an auto-increment primary key) 如果使用GenerationType.AUTO代替IDENTITY(用于自动增量主键),我也会遇到相同的异常

public class myExampleClass {

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;

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

相关问题 休眠异常:内部连接池已达到最大大小 - Hibernate exception: The internal connection pool has reached its maximum size 获取 HibernateException:内部连接池已达到其最大大小,当前没有可用的连接 - Getting HibernateException : The internal connection pool has reached its maximum size and no connection is currently available Java/Hibernate - 异常:内部连接池已达到其最大大小,当前没有可用的连接 - Java/Hibernate - Exception: The internal connection pool has reached its maximum size and no connection is currently available Java/Hibernate 错误:检测到连接泄漏。 内部连接池已达到最大大小,当前没有可用连接 - Java/Hibernate Error: Connection leak detected. The internal connection pool has reached its maximum size and no connection is currently available 如何选择最大连接池大小? - how to choose maximum connection pool size? Hibernate 配置连接池大小 - Hibernate config connection pool size 高休眠连接池大小 - High Hibernate Connection Pool Size 已解决:HIBERNATE:几分钟后达到内部连接池限制 - SOLVED: HIBERNATE: Internal Connection Pool limit reached after a few minutes HikaiCP:如何查看连接池大小? - HikaiCP : How to see the connection pool size? 如何以编程方式确定连接池大小? - How to determine connection pool size programmatically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM