我在从 oracle db web-app 上下文迁移到 postgresql db web-app 上下文时遇到问题。
我有一个简单的 java spring-mvc 网络应用程序,它带有 flyway 以初始化数据库进程并 hibernate 以管理对象。这个 web 应用程序最初想使用 oracle 数据库,我正在尝试使用 postgresql 基础,但我对这个基础很陌生,对数据源的声明不满意。也许您会发现问题所在。
我在 eclipse 插件中使用 tomcat apache 服务器 (v6) 来调试我的 web 应用程序。
当我试图在我的服务器上运行我的网络应用程序时,服务器无法启动并显示以下日志:
11:23:57.903 [main] INFO o.h.tool.hbm2ddl.SchemaUpdate - HHH000228: Running hbm2ddl schema update
11:23:57.903 [main] INFO o.h.tool.hbm2ddl.SchemaUpdate - HHH000102: Fetching database metadata
11:23:57.903 [main] ERROR o.h.tool.hbm2ddl.SchemaUpdate - HHH000319: Could not get database metadata
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.postgresql.Driver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136) ~[tomcat-dbcp.jar:na]
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) ~[tomcat-dbcp.jar:na]
[...]
Caused by: java.lang.UnsupportedClassVersionError: org/postgresql/Driver : Unsupported major.minor version 51.0
我已将驱动程序添加到我的 pom.xml
org.postgresql
postgresql
9.4-1200-jdbc41
并制作了
mvn eclipse:eclipse
我正在使用在我的 META-INF 目录中声明的数据源:
auth="Container"
type="javax.sql.DataSource"
username="postgres"
password="postgres"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/my_schema"
/>
我什至将驱动程序 .jar 添加到我的 tomcat lib 目录 (CATALINA_HOME/lib)。
Cảm ơn trước.
问候,罗曼。
我遇到了同样的问题,就我而言,我只是在“apache-tomcat-6.0.44/lib”文件夹中插入了库“postgresql-8.0-314jdbc3.jar”,它运行完美。
我在 Tomcat 服务器运行时环境中使用 JDK 1.8.0_60。
Tôi là một lập trình viên xuất sắc, rất giỏi!