我是 Java/Hibernate 的新手,我不知道这个错误意味着什么。ERROR: Connection leak detected: there are 1 unclosed connections upon shutting down pool jdbc:mysql://localhost:3306/hb_student_records?useSSL=false&serverTimezone=UTCException in thread "main" org.hibernate.HibernateException: The internal connection pool has reached its maximum size and no connection is currently available!我在 Stack Overflow 的其他论坛上查找了答案,但对我来说没有任何意义。我的课程如下:创建学生演示package com.rsharma.hibernate.demo;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;import com.rsharma.hibernate.demo.entity.Student;public class CreateStudentDemo { public static void main(String[] args) { // create session factory SessionFactory factory = new Configuration() .configure("hibernate.cfg.xml") .addAnnotatedClass(Student.class) .buildSessionFactory(); // create session Session session = factory.getCurrentSession(); try { // create a student object System.out.println("Creating new student object..."); Student tempStudent = new Student("Rishav", "Sharma", "paul@luv2code.com"); // start a transaction session.beginTransaction(); // save the student object System.out.println("Saving the student..."); session.save(tempStudent); // commit transaction session.getTransaction().commit(); System.out.println("Done!"); } finally { factory.close(); } }}
添加回答
举报
0/150
提交
取消