Migrate from JavaDB to PostgreSQL and cant access database any longer
I have an application on Glassfish v2 ( on Mac OS 10.5.8 and Java 1.6 ) that uses JavaDB and Toplinks that comes with the Glassfish bundle. Everything works fine.
I have installed PostgreSQL 8.4 and the JDBC v4 driver. Both Glassfish and Postgres server run on localhost. From Netbeans, I create a connection to a database on the Postgres server, and it works fine, I can manually create and delete tables.
I create a connection pool, resource and persistence unit for this connection to the Posgres server. When I deploy I have the following error :
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 MyC开发者_Python百科onnectionPool.
Exception : Connection could not be allocated because:
FATAL: database "null" does not exist
I read that with Postgres 8.4, localhost request are accepted by default, so I haven't changed anything in postgres.conf.
I am missing something, but I cant see what. Thanks in advance for any hint.
Tart
First ensure that MacOSX/GlassFish really uses the specified Java version (test with: java -version). Then try the following:
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
and
asadmin create-jdbc-resource --connectionpoolid test-pool jdbc/Postgres
remember to change the username, password, server, port and database to reflect your setup. Then test the datasource using:
asadmin ping-connection-pool test-pool
if this does not work then you have miss-configured your data source.
I don't know the stack, but it sounds like you haven't specified the database name in the connection. See http://jdbc.postgresql.org/documentation/84/connect.html for a list of parameters you can/should set on the connection.
精彩评论