SPRING3+HIBERNATE4配置错误
数据库服务均已开启,URL,用户名,密码没有错误;已经通过JDBC程序验证,WEB程序启动没有问题,但是当访问数据库的时候报错jdbc.properties(部分):jd...
数据库服务均已开启,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. 展开
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. 展开
1个回答
展开全部
<!-- 配置数据源 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${hibernate.driverClassName}"/>
<property name="url" value="${hibernate.url}"/>
<property name="username" value="${hibernate.username}"/>
<property name="password" value="${hibernate.password}"/>
</bean>
你配置数据源时,name里面的值写错了
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${hibernate.driverClassName}"/>
<property name="url" value="${hibernate.url}"/>
<property name="username" value="${hibernate.username}"/>
<property name="password" value="${hibernate.password}"/>
</bean>
你配置数据源时,name里面的值写错了
更多追问追答
追问
如果写成这样,启动就报错;我已经试过了。DriverManagerDataSource根本就没有username这个属性,有的属性只是user
追答
那个是可以的,我一直用的那个,你如果没有的话就是jar包版本不一样
你把jdbc.properties中jdbc.url改成jdbc.url=jdbc:oracle:thin:scott/scott@localhost:1521:ORCL
试一下
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询