gpt4 book ai didi

java - hibernate :OutOfMemoryError: PermGen space

转载 作者:搜寻专家 更新时间:2023-11-01 04:01:34 28 4
gpt4 key购买 nike

<分区>

有人能告诉我我的申请有什么问题吗?

public class HibernateUtil {
private static final SessionFactory sessionFactory;

static {
try {
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}

public boolean insertUser(User user) {
Session session = HibernateUtil.getSessionFactory().openSession();
try {
session.beginTransaction();
session.save(user);
session.getTransaction().commit();

} catch (HibernateException he) {
session.getTransaction().rollback();
return false;
}finally{
if (session != null){
session.close();
}
}

return true;
}

这是我在数据库中插入用户时调用的唯一方法,如果我尝试插入另一个用户,则启动此异常:

Initial SessionFactory creation failed.java.lang.OutOfMemoryError: PermGen space

更新:我不知道 hibernate.cfg 中是否有内容,但在这里:

<?xml version="1.0" encoding="UTF-8"?>

org.hibernate.dialect.MySQL方言 com.mysql.jdbc.驱动程序 jdbc:mysql://localhost:3306/XXXXX XXXX XXXXc 线程

    <!-- Connection pool C3P0 -->
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.timeout">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">60</property>

<!-- To show sql output on the screen -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>

<!-- Mapping the tables in my schema -->
...

</session-factory>

为什么会发生这种情况以及如何解决?

最好的问候,瓦尔特·恩里克。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com