日期:2014-05-18  浏览次数:20594 次

SPRING3+HIBERNATE4配置错误
数据库服务均已开启,URL,用户名,密码没有错误;已经通过JDBC程序验证,WEB程序启动没有问题,但是当访问数据库的时候报错
jdbc.properties(部分):
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:ORCL
jdbc.username=scott
jdbc.password=scott
spring.xml:
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
            </list>
        </property>
    </bean>     
    <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
        <property name="driver" value="${jdbc.driverClassName}"></property>
        <property name="driverUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maximumConnectionCount" value="${proxool.maxConnCount}" />
<property name="minimumConnectionCount" value="${proxool.minConnCount}" />
        <property name="statistics" value="${proxool.statistics}" />
<property name="simultaneousBuildThrottle" value="${proxool.simultaneousBuildThrottle}" />
<property name="trace" value="${proxool.trace}" />
<property name="verbose" value="${proxool.verbose}" />
   </bean>
具体错误信息如下:
严重: Exception occurred during processing request: Could not open Hibernate Session for transaction; nested exception is java.lang.UnsupportedOperationException: You should configure the username and password within the proxool configuration and just call getConnection() instead.
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.UnsupportedOperationException: You should configure the username and password within the proxool configuration and just call getConnection() instead.

------解决方案--------------------
引用:
这个才是你楼主一样的问题:http://www.yxad.com/sina/1637804941646367100.html。
dataSource配置错误,应该改为<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

反正我是这样配置的,不知道楼主哪里COPY来的代码是用ProxoolDataSource。
------解决方案--------------------
换一种hibernate数据库连接池试试看吧。下面介绍了三种:
http://blog.knowsky.com/223499.htm