postgresql - 从 JavaDB 迁移到 PostgreSQL 并且无法再访问数据库

标签 postgresql jpa jdbc glassfish

我在 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/

相关文章:

ruby-on-rails - 获取带有特定字符串的所有行

postgresql - 转换 Exec 参数 $2 类型 : invalid character ‘b’ looking for beginning of value

jpa - 通过使用 Vaadin-CDI-Integration Addon 启用 EJB 注入(inject) Vaadin 7 UI

jpa - 将基于 ORM 的 Spring 项目 (Hibernate/JPA) 迁移到 noSQL (MongoDB/Cassandra/CauchDB)

java - JDBC:为准备好的语句生成主键值

java - 无法通过 eclipse 连接到 mysql - java.lang.ClassNotFoundException : com. mysql.jdbc.Driver

postgresql - 不能在只读事务中执行 nextval()

sql - 记录 "old"尚未分配

java - 如何在 JPA 中删除具有外主键的对象?

java - Spring JDBC - 配置构建路径警告错误显示