java.sql.SQLException:tomcat 8.5上没有合适的驱动程序

时间:2018-06-12 21:13:53

标签: java spring oracle tomcat jdbc

我在eclipse上的tomcat上启动应用程序时遇到异常。

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

Spring config

<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上收到错误。

1 个答案:

答案 0 :(得分:-1)

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

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

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

请参阅此图片以查看OracleDriver类路径