You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IllegalStateException:无法加载JDBC驱动,添加ojdbc14.jar仍报错求助

Fixing "Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]" Error

Hey there, let's work through this frustrating JDBC driver issue together. You mentioned you added ojdbc14.jar to src/main/resources/lib but still hit the error—here are the most common fixes to get this sorted:

  • Don't rely on src/main/resources/lib for dependencies
    That directory is meant for resource files (like properties, XML configs), not JAR dependencies. Build tools like Maven/Gradle won't automatically include JARs here in your project's classpath. Instead:

    • If using Maven, install the JAR to your local repository first with this command (replace the file path with your actual ojdbc14.jar location):
      mvn install:install-file -Dfile=/path/to/ojdbc14.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar
      
      Then add this dependency to your pom.xml:
      <dependency>
          <groupId>com.oracle</groupId>
          <artifactId>ojdbc14</artifactId>
          <version>10.2.0.4.0</version>
      </dependency>
      
    • If you're not using a build tool, manually add the JAR to your IDE's classpath:
      • In IntelliJ: Right-click the ojdbc14.jar → Add as Library
      • In Eclipse: Right-click your project → Build Path → Add External Archives
  • Double-check your driver class name
    While oracle.jdbc.driver.OracleDriver is valid for ojdbc14, make sure there are no typos (case sensitivity matters!). For reference, newer Oracle drivers use oracle.jdbc.OracleDriver, but the older one should still work here.

  • Verify the JAR file is intact
    Sometimes downloaded JARs get corrupted. Try re-downloading a fresh copy of ojdbc14.jar from a trusted source and replace the existing one in your project.

  • Check your Spring config for typos
    Ensure your Spring bean configuration (XML or annotation-based) has the correct driverClassName property. For example, in XML:

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <!-- other properties like url, username, password -->
    </bean>
    

    Make sure there are no extra spaces or incorrect spelling in the value.


内容的提问来源于stack exchange,提问作者Soham Banerjee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:14:55