我在 Glassfish v2(在 Mac OS 10.5.8 和 Java 1.6 上)上有一个应用程序,它使用 Glassfish bundle 附带的 JavaDB 和 Toplinks。一切正常。
我已经安装了 PostgreSQL 8.4 和 JDBC v4 驱动程序。 Glassfish 和 Postgres 服务器都在本地主机上运行。从 Netbeans,我创建了一个到 Postgres 服务器上的数据库的连接,它工作正常,我可以手动创建和删除表。
我为这个到 Posgres 服务器的连接创建了一个连接池、资源和持久单元。部署时出现以下错误:
ADM1041:Sent the event to instance:
[ResourceDeployEvent -- reference-added jdbc/jdbc/MyDatasource]
CORE5004: Resource Deployed: [jdbc:jdbc/MyDatasource].
TopLink, version: Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))
Server: unknown
RAR5038:Unexpected exception while creating resource for pool MyConnectionPool.
Exception : Connection could not be allocated because:
FATAL: database "null" does not exist
我读到 Postgres 8.4 默认接受本地主机请求,所以我没有在 postgres.conf 中更改任何内容。
我错过了什么,但我看不到什么。 提前感谢您的任何提示。
酸辣的
最佳答案
首先确保 MacOSX/GlassFish 确实使用指定的 Java 版本(测试:java -version)。然后尝试以下操作:
asadmin create-jdbc-connection-pool
--datasourceclassname org.postgresql.ds.PGSimpleDataSource
--restype javax.sql.DataSource --property portNumber=5432:password=secret:user=postgres:serverName=localhost:databaseName=postgres
test-pool
和
asadmin create-jdbc-resource --connectionpoolid test-pool jdbc/Postgres
记得更改用户名、密码、服务器、端口和数据库 以反射(reflect)您的设置。然后使用以下方法测试数据源:
asadmin ping-connection-pool test-pool
如果这不起作用,那么您的数据源配置有误。
关于postgresql - 从 JavaDB 迁移到 PostgreSQL 并且无法再访问数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1939444/