hibernate connection pool

前端 未结 2 1649
温柔的废话
温柔的废话 2020-12-02 09:32

I can\'t seem to get hibernate to use c3p0 for connection pooling, it says

12:30:35,038  INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in c         


        
相关标签:
2条回答
  • 2020-12-02 09:56
    <!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory>
    
            <!-- datasource config -->
            <property name="connection.url">jdbc:mysql://localhost:3306/db?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    
            <property name="connection.username">user</property>
            <property name="connection.password">pass</property>
    
            <!-- c3p0 config http://www.hibernate.org/214.html -->
            <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>        
            <property name="hibernate.c3p0.acquire_increment">1</property>
            <property name="hibernate.c3p0.idle_test_period">60</property>
            <property name="hibernate.c3p0.min_size">1</property>
            <property name="hibernate.c3p0.max_size">2</property>
            <property name="hibernate.c3p0.max_statements">50</property>
            <property name="hibernate.c3p0.timeout">0</property>
            <property name="hibernate.c3p0.acquireRetryAttempts">1</property>
            <property name="hibernate.c3p0.acquireRetryDelay">250</property>
    
            <property name="hibernate.show_sql">true</property>
            <property name="hibernate.use_sql_comments">true</property>
    
            <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
            <property name="hibernate.current_session_context_class">thread</property>
    
            ...
    
        </session-factory>
    </hibernate-configuration>
    
    0 讨论(0)
  • 2020-12-02 10:15

    The best way to resolve these DTD (Document Type Definition) mappings issues is to

    1. Take the hibernate jar file and unizip/jar and get the two files - hibernate-configuration dtd file and hibernate-mapping dtd file.

    2. Copy the DTD declaration from these two files and use them in your cfg.xml and hbm.xml respectively.

    This resolved the issue for me.

    0 讨论(0)
提交回复
热议问题