pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: luke@chipcity.com.au
To: pgsql-jdbc@postgresql.org
Subject: Re: DataSource lookup
Date: Mon, 4 Apr 2005 06:24:35 +0930
Message-ID: <20050403205435.GB1806@bench.chipcity.com.au> (raw)
In-Reply-To: <d2od8k$c4s$1@news.hub.org>
References: <d2od8k$c4s$1@news.hub.org>

Hi,

03Apr2005 @ 11:33 Nico thusly spake
> How do I find out what's the name of the JNDI data source I need for a 
> PostgreSQL connection pool?
> Currently I do this,
> 
> javax.naming.Context env=(javax.naming.Context)
> new javax.naming.InitialContext().lookup("java:comp/env");
> pool=(DataSource)env.lookup("jdbc/"+dbname);
> connection=pool.getConnection("username","password");
> 
> but then I get a MySQL connection(MySQL & PostgreSQL run both on server).
> I only have permission to my personal account, not the shared directories 
> where I think the jndi resources are located. In my web.xml are no resources 
> defined.

You can define the datasource in the context.xml file in the META-INF directory in your webapp.
You should have permissions for that because you should have permissions for the webapp 
You can also define a datasource in the server.xml file, however that is in the 'server-root' conf file and it sounds like you don't have permission for that.

Here is an example from a context.xml file:

-this one is connecting to a cloudscape database, see 'driverClassName' (for postgres: 'org.postgresql.Driver')
-the url for a postgresql database would be 'jdbc:postgresql:dbname'
 ___________________________
/
<?xml version="1.0" encoding="UTF-8"?>
<Context path="">
  <Logger className="org.apache.catalina.logger.FileLogger" 
    prefix="ROOT." 
    suffix=".log" 
    timestamp="true"/>
  <Resource 
    driverClassName="COM.cloudscape.core.RmiJdbcDriver" 
    maxActive="4" 
    maxIdle="2" 
    maxWait="5000" 
    name="jdbc/dmit" 
    password="" 
    type="javax.sql.DataSource" 
    url="jdbc:cloudscape:rmi://localhost:1099/CloudscapeDB" 
    username=""/>
  <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
\_____________________________

hth,
Luke
-- 
............._
.|  .| |.|/.|_
.|__.|_|.|\.|_
.0421 276 282.



view thread (3+ messages)  latest in thread

Message-ID: <20050403205435.GB1806@bench.chipcity.com.au>
Permalink:  ../20050403205435.GB1806@bench.chipcity.com.au/
Also on:    postgresql.org/message-id/20050403205435.GB1806@bench.chipcity.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: luke@chipcity.com.au
  Subject: Re: DataSource lookup
  In-Reply-To: <20050403205435.GB1806@bench.chipcity.com.au>
  References: <d2od8k$c4s$1@news.hub.org> <20050403205435.GB1806@bench.chipcity.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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