奇数连接错误 - JDBC无法找到数据库,但psql可以

时间:2012-07-25 20:38:20

标签: postgresql jdbc

使用JDBC连接到数据库时,我看到了连接错误。但是,我可以使用psql连接到同一个数据库。这是我的连接字符串:

"jdbc:postgresql://127.0.0.1:5432/sample?user=postgres&password=postgres&loglevel=2"

我在连接时看到以下日志,然后是PSQLException。

16:33:49.425 (1) PostgreSQL 9.1 JDBC4 (build 901)
16:33:49.431 (1) Trying to establish a protocol version 3 connection to 127.0.0.1:5432
16:33:49.443 (1)  FE=> StartupPacket(user=postgres, database=sample, client_encoding=UTF8, DateStyle=ISO, extra_float_digits=2)
16:33:49.448 (1)  <=BE AuthenticationReqMD5(salt=da8b7230)
16:33:49.449 (1)  FE=> Password(md5digest=md5dc7d3827e761b7b18f553d6bdd15fa21)
16:33:49.451 (1)  <=BE AuthenticationOk
16:33:49.467 (1)  <=BE ErrorMessage(FATAL: database "sample" does not exist)
org.postgresql.util.PSQLException: FATAL: database "sample" does not exist

但是,我可以使用psql命令

进行正常连接
$ psql -U postgres sample
psql (9.1.4)
Type "help" for help.

sample=#

我还可以尝试隔离这个问题吗?

0 个答案:

没有答案
相关问题