pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feed'FATAL: database "null" does not exist ' when accessing through a datasource
5+ messages / 2 participants
[nested] [flat]
* 'FATAL: database "null" does not exist ' when accessing through a datasource
@ 2006-01-14 04:45 Joeseph Blowseph <joseph_blowseph@hotmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Joeseph Blowseph @ 2006-01-14 04:45 UTC (permalink / raw)
To: pgsql-jdbc
I've set up a datasource to access a database on the local machine. The
database was installed in the default location on the default port. Whenever
I try to make a connection to the database I get an error, usually this one.
org.postgresql.util.PSQLException: FATAL: database "null" does not exist
I've tried every conceivable permuation of the url (and a few inconceivable
ones). The datasource is set up like this:
DataSourceClass: org.postgresql.ds.PGSimpleDataSource
JNDI Name: jdbc/PGSimple
URL: jdbc:postgresql://localhost:5432/PGSQL1
And the code to access it is like this:
InitialContext ic = new InitialContext();
PGSimpleDataSource PGDS =
(PGSimpleDataSource) ic.lookup("jdbc/PGSimple);
Connection PGSimpleConn = PGDS.getConnection();
/* do Stuff /*
PGSimpleConn.close();
That code fails with the above error. But if I add this statement, it works
okay:
PGDS.setDatabaseName("PGSQL1");
I can't understand why I can't specify the databasename in the URL.
The container is OC4J running in Oracle Jdeveloper.
Any thoughts would be very much appreciated.
_________________________________________________________________
Are you using the latest version of MSN Messenger? Download MSN Messenger
7.5 today! http://messenger.msn.co.uk
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'FATAL: database "null" does not exist ' when accessing
@ 2006-01-14 11:21 Oliver Jowett <oliver@opencloud.com>
parent: Joeseph Blowseph <joseph_blowseph@hotmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Oliver Jowett @ 2006-01-14 11:21 UTC (permalink / raw)
To: Joeseph Blowseph <joseph_blowseph@hotmail.com>; +Cc: pgsql-jdbc
Joeseph Blowseph wrote:
> DataSourceClass: org.postgresql.ds.PGSimpleDataSource
> JNDI Name: jdbc/PGSimple
> URL: jdbc:postgresql://localhost:5432/PGSQL1
If you're using a DataSource, then the internal JDBC URL to use is
constructed from the parameters used to configure the datasource
(setDatabaseName, etc).
I don't know what your container is doing with the "JDBC URL" bit, but
AFAIK it's not used by the datasource at all.
-O
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'FATAL: database "null" does not exist ' when accessing through a
@ 2006-01-14 16:59 Joeseph Blowseph <joseph_blowseph@hotmail.com>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 5+ messages in thread
From: Joeseph Blowseph @ 2006-01-14 16:59 UTC (permalink / raw)
To: oliver@opencloud.com; +Cc: pgsql-jdbc
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.
>From: Oliver Jowett <oliver@opencloud.com>
>To: Joeseph Blowseph <joseph_blowseph@hotmail.com>
>CC: pgsql-jdbc@postgresql.org
>Subject: Re: [JDBC] 'FATAL: database "null" does not exist ' when accessing
>through a datasource
>Date: Sat, 14 Jan 2006 11:21:12 +0000
>
>Joeseph Blowseph wrote:
>
>>DataSourceClass: org.postgresql.ds.PGSimpleDataSource
>>JNDI Name: jdbc/PGSimple
>>URL: jdbc:postgresql://localhost:5432/PGSQL1
>
>If you're using a DataSource, then the internal JDBC URL to use is
>constructed from the parameters used to configure the datasource
>(setDatabaseName, etc).
>
>I don't know what your container is doing with the "JDBC URL" bit, but
>AFAIK it's not used by the datasource at all.
>
>-O
_________________________________________________________________
The new MSN Search Toolbar now includes Desktop search!
http://toolbar.msn.co.uk/
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'FATAL: database "null" does not exist ' when accessing
@ 2006-01-14 21:24 Oliver Jowett <oliver@opencloud.com>
parent: Joeseph Blowseph <joseph_blowseph@hotmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Oliver Jowett @ 2006-01-14 21:24 UTC (permalink / raw)
To: Joeseph Blowseph <joseph_blowseph@hotmail.com>; +Cc: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'FATAL: database "null" does not exist ' when accessing through a
@ 2006-01-14 22:05 Joeseph Blowseph <joseph_blowseph@hotmail.com>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 0 replies; 5+ messages in thread
From: Joeseph Blowseph @ 2006-01-14 22:05 UTC (permalink / raw)
To: oliver@opencloud.com; +Cc: pgsql-jdbc
Thanks for the comprehensive answer.
I was assuming that the container was parsing the database name from the
URL. I've also been running into an "Invalid Oracle URL" error while I've
been trying to get this working. That didn't seem to make much sense when
the driver specified is Postgres. I think the two errors may be related.
Oracle profess their container to be database-independent, but I'm not so
sure! I have a thread open in the Oracle forum and I did feel that the
problem lies with them; I just thought I'd ask here to see if I could get
any further clarification. And I did :-)
>From: Oliver Jowett <oliver@opencloud.com>
>To: Joeseph Blowseph <joseph_blowseph@hotmail.com>
>CC: pgsql-jdbc@postgresql.org
>Subject: Re: [JDBC] 'FATAL: database "null" does not exist ' when accessing
>through a datasource
>Date: Sun, 15 Jan 2006 10:24:01 +1300
>
>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
_________________________________________________________________
Are you using the latest version of MSN Messenger? Download MSN Messenger
7.5 today! http://messenger.msn.co.uk
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2006-01-14 22:05 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-14 04:45 'FATAL: database "null" does not exist ' when accessing through a datasource Joeseph Blowseph <joseph_blowseph@hotmail.com>
2006-01-14 11:21 ` Re: 'FATAL: database "null" does not exist ' when accessing Oliver Jowett <oliver@opencloud.com>
2006-01-14 16:59 ` Re: 'FATAL: database "null" does not exist ' when accessing through a Joeseph Blowseph <joseph_blowseph@hotmail.com>
2006-01-14 21:24 ` Re: 'FATAL: database "null" does not exist ' when accessing Oliver Jowett <oliver@opencloud.com>
2006-01-14 22:05 ` Re: 'FATAL: database "null" does not exist ' when accessing through a Joeseph Blowseph <joseph_blowseph@hotmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox