我的应用程序尝试使用Jdbc驱动程序版本连接到PostgreSQL时出现了一个奇怪的问题:8.4-702.jdbc4
似乎找不到persistence.xml中定义的数据库所在的位置。
错误:
[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
但是我可以在shell中解决这个问题:
$ psql -U postgres -h 192.168.145.128
的persistence.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>
可能是什么问题?
答案 0 :(得分:0)
在我的情况下,这是因为给出了错误的用户名和密码。