【问题标题】:cannot load the oracle driver无法加载 oracle 驱动程序
【发布时间】:2013-05-08 19:38:18
【问题描述】:

大家好,还有一个问题 以下是资料

如果需要更多信息,请在 cmets 中告诉我

INFO:销毁 org.springframework.beans.factory.support.DefaultListableBeanFactory@7471dc3d 中的单例:定义 bean [dataSource,studentJDBCTemplate];工厂层次结构的根 线程“主”org.springframework.beans.factory.BeanCreationException 中的异常:创建类路径资源 [pack1/config.xml] 中定义的名称为“studentJDBCTemplate”的 bean 时出错:设置属性值时出错;嵌套异常是 org.springframework.beans.PropertyBatchUpdateException;嵌套的 PropertyAccessExceptions (1) 是: PropertyAccessException 1:org.springframework.beans.MethodInvocationException:Property 'dataSource' 抛出异常;嵌套异常是 java.lang.IllegalArgumentException: Property 'dataSource' is required

<?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-3.0.xsd ">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
 <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
    <property name="password" value="trg"></property>
    <property name="url" value="jdbc:oracle:thin:@172.23.3.132:1521:TRAIN"></property>
    <property name="username" value="trg12"></property>
    <!-- <property name="schema" value="TRAIN"></property> -->
 </bean>

 <bean id="studentJDBCTemplate" class="pack1.StudentJDBCTemplate"> 
 <property name="dataSource" ref="dataSource" />
 </bean>

这是我用于数据库连接的 bean ...

【问题讨论】:

  • 确保您的 OJDBC jar 在类路径中
  • 您需要将 JDBC 驱动 JAR 添加到类路径中。
  • @hoaz 谢谢大家,我已经包含了 jar 文件,但现在我再次遇到上述异常..... prev 异常已解决,这是新的......它说数据源属性必需,但我在我的 xml 中提到了该属性....
  • @Jesper 谢谢大家,我已经包含了 jar 文件,但现在我再次收到上面提到的异常..... prev 异常已解决,这是新的......它说数据源属性必需,但我在我的 xml 中提到了该属性....
  • 您的主题具有误导性,因为在您的堆栈跟踪中它没有抱怨 oracle 驱动程序。

标签: java spring jdbc javabeans


【解决方案1】:

从异常看来,您的类 pack1.StudentJDBCTemplate 没有 dataSource 属性。

您确定该类扩展了 JDBCTemplate 或其他具有 dataSource 属性的类吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-24
    • 1970-01-01
    • 2020-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    • 2016-05-11
    相关资源
    最近更新 更多