我试图用Maven开发一个Java应用程序,同时使用Hibernate和PostgreSQL数据库进行持久化.我不明白如何将PostgreSQL驱动程序连接到我的应用程序.我知道你在Maven的pom中添加了依赖项.xml文件,它从远程存储库中查找JAR,但其他JAR呢?

推荐答案

PostgreSQL驱动程序JAR包含在Maven的中央存储库中:

对于高达9.1的PostgreSQL,请使用:

<dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>VERSION</version>
</dependency>

还是9.2+

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>VERSION</version>
</dependency>

(Thanks to @Caspar for the correction)

Postgresql相关问答推荐

在Postgres中如何连接具有相同名称列的表并更改列名称?

PostgreSQL:如何从另一列的 json 值替换为一列?

如何获取在 Go 中完成的 SQL 插入的错误详细信息?

包含间隔在 jooq 和 postgres 中没有按预期工作

在 jOOQ 中 Select 相同的命名列

从具有加权行概率的 PostgreSQL 表中 Select 随机行

处理 sqlalchemy 断开连接的更好方法

PostgreSQL - jsonb_each

使用 postgres regexp_replace 将字符串列表替换为始终相同的字符串

gem install pg 无法绑定到 libpq

Postgres 删除表语法错误

postgresql:致命:password authentication failed for user "douglas"

如何使用 node-postgres 将多行正确插入 PG?

适配器 Ecto.Adapters.Postgres 未编译

PostgreSQL 中跨多个表的索引

如果 PostgreSQL count(*) 总是很慢,如何对复杂查询进行分页?

PostgreSQL 使用 UUID 与文本作为主键

删除空行

如何在postgres中将整数分钟转换为间隔

Rails 5 db 迁移:如何修复 ActiveRecord::ConcurrentMigrationError