Home > Archive > PostgreSQL JDBC > January 2006 > Re: 'FATAL: database "null" does not exist ' when accessing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: 'FATAL: database "null" does not exist ' when accessing
Oliver Jowett

2006-01-14, 8:23 pm

Joeseph Blowseph wrote:
> The datasource construction parameters are stored in a data-sources xml
> file like this:
>
> <native-data-source name="PGDS1"
> data-source-class="org.postgresql.ds.PGPoolingDataSource"
> jndi-name="jdbc/PGPooling"
> user="postgres" password="password"
> url="jdbc:postgresql://localhost:5432/PGSQL1"/>
>
> ...
>
> The program code does a jdni lookup for the DataSource. That means that
> you don't have to hard-code connection details into the source. But, as
> things stand, I have to hard-code the database name.


Sorry, I guess I wasn't clear.

Your container will be constructing a PGPoolingDataSource object, then
calling various JavaBean-property-style methods on it to initialize it.
These are methods such as setUser(), setPassword(), and setDatabaseName().

When PGPoolingDataSource is asked for a connection, it constructs a
driver URL from the various properties it is configured with and then
requests a connection with that URL.

The set of properties provided by a particular DataSource implementation
can vary -- the container is meant to use introspection to find and
invoke the property accessors.

PGPoolingDataSource does not have a "url" property, it does not provide
setURL() or similar. So I don't know what the container is doing with
that "url" parameter, but it's not being set on the DataSource for sure.
As the URL you specify never makes it to the DataSource, it's not
suprising that the information you specify there is not used.

You need to persuade your container to call the JavaBean accessor
setDatabaseName() on the DataSource before use. Perhaps you could try
adding an attribute called databaseName to your <native-data-source>
configuration element above?

This is why manually calling setDatabaseName fixes the "problem" -- but
it's the container's job to call it, as you say. So complain to your
container's vendor.. the PG datasource is working as designed, AFAIK.

-O

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com