1

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 MyConnectionPool.  
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

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

The first phrase makes no sense. JDBC4 requires Java SE 6, not Java EE 6. Java EE 5 can run perfectly on top of Java SE 6. This is not the problem.
Thanks. The driver was actually correct, but creating the ConnectionPool directly in the JavaEE server instead of doing via Netbeans worked. I am not sure what I did wrong setting the ConnectionPool via the wizard in Netbeans though, but at least the problem is solved :o)
fixed the the JDBC driver version part, as correctly pointed out by BalusC.
0

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.

1 Comment

I think the connection is ok, as I can manually access the database using it. It is define this way : <property name="URL" value="jdbc:postgresql://localhost:5432/MyDB"/> <property name="User" value="postgres"/> <property name="Password" value="foo"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.