gpt4 book ai didi

java.sql.SQLException : No suitable driver on tomcat 8. 5

转载 作者:行者123 更新时间:2023-11-28 23:54:57 24 4
gpt4 key购买 nike

当我在 eclipse 上的 tomcat 上启动应用程序时出现异常。

版本

ojdbc7-12.1.0.1.jar    
apache-tomcat-8.5.31
jdk-8u172-windows-x64

Spring 配置

<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="${database.connection.url}" />
<property name="username" value="${database.user}" />
<property name="password" value="${database.pwd}" />
<property name="initialSize" value="${database.pool.initialSize}" />
<property name="maxTotal" value="${database.pool.maxTotal}" />
<property name="maxIdle" value="${database.pool.maxIdle}" />
<property name="minIdle" value="${database.pool.minIdle}" />
<property name="maxWaitMillis" value="${database.pool.maxWaitMillis}" />
</bean>

属性

database.user=dev
database.pwd=dev
database.connection.url=jdbc:oracle:thin@X.X.X.X:1521:DATABASE

异常:

Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
Caused by: java.sql.SQLException: Cannot create JDBC driver of class 'oracle.jdbc.OracleDriver' for connect URL 'jdbc:oracle:thin@X.X.X.X:1521:DATABASE'
at org.apache.commons.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2161)
Caused by: java.sql.SQLException: No suitable driver
at org.apache.commons.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2152)

我试图将驱动程序jar 放在tomcat 的lib 文件夹中,但同样的错误

我在 Wildfly 10.1 上也遇到了错误。

最佳答案

我看到您指的是 Oracle 7 jar 中的错误包。使用 OracleDriver 类名如下 oracle.jdbc.driver.OracleDriver

<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />

您始终可以打开 jar 并找到 OracleDriver 的类:enter image description here

请引用此图查看 OracleDriver 类路径

关于java.sql.SQLException : No suitable driver on tomcat 8. 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50825910/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com