0

我正在使用 spring 一个 Hibernate,这里是 Hibernate.properties 问题是即使有 c3p0 设置,连接提供程序也不会更改为 c3p0ConnectionProvider。它们只是被加载,似乎什么也没做。

    hibernate.show_sql=true
hibernate.hbm2ddl.auto=validate
hibernate.c3p0.testConnectionOnCheckin = true
hibernate.c3p0.checkoutTimeout = 0
hibernate.c3p0.acquireIncrement=5
hibernate.c3p0.idleConnectionTestPeriod=3000
hibernate.c3p0.initialPoolSize=10
hibernate.c3p0.maxIdleTime=300
hibernate.c3p0.maxPoolSize=50
hibernate.c3p0.maxStatements=100
hibernate.c3p0.minPoolSize=5
hibernate.c3p0.testConnectionsOnCheckout=true

这是堆栈跟踪。

            main INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization started
    main INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@70074fd2: display name [Root WebApplicationContext]; startup date [Thu May 24 15:39:51 MDT 2012]; root of context hierarchy
    main INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/core-data-annotation-context.xml]
    main INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/core-data-datasource-context.xml]
    main INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
    main INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
    main INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
    main INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/core-profile-datasource-context.xml]
    main INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@70074fd2]: org.springframework.beans.factory.support.DefaultListableBeanFactory@2f41eb55
    main INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2f41eb55: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,pagingProviderHibernate,daoEager,dao,coreDataResourceLocator,cachingService,randomUtilService,randomWordGenerationService,placeHolderResolver,logsDbDao,subsetDbDao,profilesdbDao,resourceProfileLoaderNew,org.springframework.context.config.internalBeanConfigurerAspect,cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.servlet.ServletTransportFactory,infobutton-service,dataSource,sessionFactory,hibernateTemplate,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,subsetlogDao,logDao,profiledataSource,profilesessionFactory,profilehibernateTemplate,profiletransactionManager,profilesDao,pDao]; root of factory hierarchy
    main INFO [org.springframework.beans.factory.config.PropertiesFactoryBean] - Loading properties file from ServletContext resource [/WEB-INF/datasource-mysql.properties]
    main INFO [org.springframework.beans.factory.config.PropertiesFactoryBean] - Loading properties file from ServletContext resource [/WEB-INF/hibernate.properties]
    main INFO [org.springframework.beans.factory.config.PropertiesFactoryBean] - Loading properties file from ServletContext resource [/WEB-INF/datasource-mysql.properties]
    main INFO [org.hibernate.cfg.annotations.Version] - Hibernate Annotations 3.4.0.GA
    main INFO [org.hibernate.cfg.Environment] - Hibernate 3.3.1.GA
    main INFO [org.hibernate.cfg.Environment] - loaded properties from resource hibernate.properties: {hibernate.c3p0.maxStatements=100, hibernate.c3p0.maxIdleTime=300, hibernate.c3p0.idleConnectionTestPeriod=3000, hibernate.c3p0.testConnectionOnCheckin=true, hibernate.c3p0.acquireIncrement=5, hibernate.c3p0.initialPoolSize=10, hibernate.c3p0.maxPoolSize=50, hibernate.c3p0.minPoolSize=5, hibernate.hbm2ddl.auto=validate, hibernate.c3p0.testConnectionsOnCheckout=true, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.c3p0.checkoutTimeout=0}
    main INFO [org.hibernate.cfg.Environment] - Bytecode provider name : javassist
    main INFO [org.hibernate.cfg.Environment] - using JDK 1.4 java.sql.Timestamp handling
    main INFO [org.hibernate.cfg.AnnotationBinder] - Binding entity from annotated class: com.asd.subsetdb.domain.Logs
    main INFO [org.hibernate.cfg.annotations.EntityBinder] - Bind entity com.asd.subsetdb.domain.Logs on table logs
    main INFO [org.hibernate.validator.Version] - Hibernate Validator 3.1.0.GA
    main INFO [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean] - Building new Hibernate SessionFactory
    main INFO [org.hibernate.search.Version] - Hibernate Search 3.4.2.Final

主要信息 [org.hibernate.connection.ConnectionProviderFactory] ​​- 初始化连接提供者:org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider

    main INFO [org.hibernate.cfg.SettingsFactory] - RDBMS: MySQL, version: 5.0.77
    main INFO [org.hibernate.cfg.SettingsFactory] - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.17 ( Revision: ${bzr.revision-id} )
    main INFO [org.hibernate.dialect.Dialect] - Using dialect: org.hibernate.dialect.MySQL5Dialect
    main INFO [org.hibernate.transaction.TransactionFactoryFactory] - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
    main INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    main INFO [org.hibernate.cfg.SettingsFactory] - Automatic flush during beforeCompletion(): disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Automatic session close at end of transaction: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch size: 15
    main INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch updates for versioned data: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Scrollable result sets: enabled
    main INFO [org.hibernate.cfg.SettingsFactory] - JDBC3 getGeneratedKeys(): enabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Connection release mode: auto
    main INFO [org.hibernate.cfg.SettingsFactory] - Maximum outer join fetch depth: 2
    main INFO [org.hibernate.cfg.SettingsFactory] - Default batch fetch size: 1
    main INFO [org.hibernate.cfg.SettingsFactory] - Generate SQL with comments: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Order SQL updates by primary key: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Order SQL inserts for batching: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    main INFO [org.hibernate.hql.ast.ASTQueryTranslatorFactory] - Using ASTQueryTranslatorFactory
    main INFO [org.hibernate.cfg.SettingsFactory] - Query language substitutions: {}
    main INFO [org.hibernate.cfg.SettingsFactory] - JPA-QL strict compliance: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Second-level cache: enabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Query cache: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
    main INFO [org.hibernate.cfg.SettingsFactory] - Optimize cache for minimal puts: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Structured second-level cache entries: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Echoing all SQL to stdout
    main INFO [org.hibernate.cfg.SettingsFactory] - Statistics: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Deleted entity synthetic identifier rollback: disabled
    main INFO [org.hibernate.cfg.SettingsFactory] - Default entity-mode: pojo
    main INFO [org.hibernate.cfg.SettingsFactory] - Named query checking : enabled
    main INFO [org.hibernate.impl.SessionFactoryImpl] - building session factory
    main INFO [org.hibernate.impl.SessionFactoryObjectFactory] - Not binding factory to JNDI, no JNDI name configured
    main INFO [org.hibernate.tool.hbm2ddl.SchemaValidator] - Running schema validator
    main INFO [org.apache.jcs.engine.control.CompositeCacheConfigurator] - setting defaultElementAttributes to [ IS_LATERAL = true, IS_SPOOL = true, IS_REMOTE = true, IS_ETERNAL = false, MaxLifeSeconds = 7200, IdleTime = 1800, CreateTime = 1337895600422, LastAccessTime = 1337895600422, getTimeToLiveSeconds() = 7199, createTime = 1337895600422 ]
4

1 回答 1

0

通过将此添加到 context/persistence.xml 进行修复

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> 
  <property name="driverClass"><value>com.mysql.jdbc.Driver</value></property> 
  <property name="jdbcUrl"><value>jdbc:mysql://localhost XXX</value>    

 </property> 
  <property name="user"><value>zzz</value></property> 
  <property name="password"><value>xxx</value></property> 
</bean>

我仍然不确定为什么没有com.mchange.v2.c3p0.ComboPooledDataSource就无法工作。

于 2012-05-25T08:16:25.007 回答