日期:2014-05-20  浏览次数:20676 次

Spring+Hibernate这是我的配置文件!但是错误显示JNDI有问题!技术菜也讲不清楚!希望有人能解决吧!
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


<bean id="MybeanIdtarget"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/leasedba"></property>
</bean>
<bean id="MybeanId"
class="org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter">
<property name="targetDataSource">
<ref bean="MybeanIdtarget" />
</property>
<property name="username" value="leasedba"></property>
<property name="password" value="leasedba"></property>
</bean>
<bean id="MySessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="MybeanId" />
</property>
<property name="hibernateProperties">
<props>
<prop key="jndi.url">
jdbc:derby://localhost:1527/leasedba
</prop>
<prop key="jndi.class">
com.sun.jndi.cosnaming.CNCtxFactory
</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
</bean>
<bean id="testDAO" class="mapping.TestDAO">
  <property name="hibernateTemplate">
  <ref bean="hibernateTemplate"/>
  </property>
  </bean>

</beans>

------解决方案--------------------
<prop key="jndi.url"> 
jdbc:derby://localhost:1527/leasedba 
</prop> 
---------------------
jndi不是jdbc,去看你用的jndi的context是啥吧