java PSQLException:FATAL:数据库“mydb”不存在

ss2ws0br  于 2023-03-16  发布在  Java
关注(0)|答案(1)|浏览(176)

我有一个奇怪的问题,我的应用程序试图连接到PostgreSQL与Jdbc驱动程序版本:8.4-702.jdbc4
它似乎找不到persistence.xml中定义的DB。

错误:

[INFO] Caused by: org.postgresql.util.PSQLException: FATAL: database "mydb" does not exist
[INFO]  at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:464)
[INFO]  at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:112)
[INFO]  at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
[INFO]  at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
[INFO]  at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
[INFO]  at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
[INFO]  at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
[INFO]  at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
[INFO]  at org.postgresql.Driver.makeConnection(Driver.java:393)
[INFO]  at org.postgresql.Driver.connect(Driver.java:267)
[INFO]  at java.sql.DriverManager.getConnection(DriverManager.java:579)
[INFO]  at java.sql.DriverManager.getConnection(DriverManager.java:221)
[INFO]  at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:89)
[INFO]  at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:72)
[INFO]  at org.apache.shiro.realm.jdbc.JdbcRealm.doGetAuthenticationInfo(JdbcRealm.java:215

然而,我可以这样做w/o的问题在 shell :

$ psql -U postgres -h 192.168.145.128

持久性.xml

<properties>
     <property name="hibernate.hbm2ddl.auto" value="update"/>
     <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://192.168.145.128:5432/mydb" />
     <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
     <property name="javax.persistence.jdbc.user" value="postgres" /> 
     <property name="javax.persistence.jdbc.password" value="postgres" /> 
  </properties>

有什么问题吗?

pokxtpni

pokxtpni1#

在我的情况下,这是因为错误的用户名和密码给.

相关问题