java.sql.SQLException:找不到合适的驱动程序jdbc:oracle:thin

时间:2015-01-21 06:45:29

标签: java spring oracle tomcat jdbc

我正在尝试在我的本地tomcat服务器中部署基于Spring的Web应用程序。以下是我的申请详情:

  • 基于Spring的Web应用程序(战争)
  • Tomcat 6服务器
  • Java 1.6
  • Oracle DB
  • 以下是jdbc配置:

    仅配置tomcat设置。 javax.persistence.jdbc.drive=oracle.jdbc.OracleDriver javax.persistence.jdbc.url=jdbc:oracle:thin:@coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS javax.persistence.jdbc.user=test javax.persistence.jdbc.password=test

  • 我还在我的/ lib文件夹中添加了ojdbc6.jar,ojdbc14.jar

我没有任何问题部署了我的war文件。但是当我的应用程序尝试连接到db时,它会抛出错误:“ java.sql.SQLException:没有为jdbc找到合适的驱动程序:oracle:thin:@ coursesdev.cvbaybp20ew7.eu-west

Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243):  org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for  jdbc:oracle:thin:@coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS
Error Code: 0
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
    at org.springframework.orm.jpa.JpaTransactionManager.createEntityManagerForTransaction(JpaTransactionManager.java:445)
   at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:366)
    ... 81 more
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS
Error Code: 0
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:109)
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:293)
    at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418)
    at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:216)
    at org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:504)
    at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:484)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:208)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)
    ... 87 more
Caused by: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@coursesdev.cvbaybp20ew7.eu-west-1.rds.amazonaws.com:1521:DEVCRS
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    ... 97 more

我看过很多关于类似问题的帖子,但我不确定我错过了什么。

1 个答案:

答案 0 :(得分:1)

此错误取决于您的建筑结构。将jar文件添加到您的lib文件夹不会做任何事情。 您应该将jar文件添加到类路径中。 如果您正在通过IDE构建项目,请说eclipse,您应该将其添加到.classpath文件中。如果您使用的是Idea,则应将其添加到.iml文件等。 如果要使用ant构建项目,则应将jar地址添加到build.xml文件中。 我想你不是在使用maven。