Re: DataSource lookup

From: "Nico" <nicohmail-postgresql(at)yahoo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DataSource lookup
Date: 2005-04-04 09:00:26
Message-ID: d2qvnj$vbm$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Thanks a lot, gonna try it out right away...
Nico.

<luke(at)chipcity(dot)com(dot)au> schreef in bericht
news:20050403205435(dot)GB1806(at)bench(dot)chipcity(dot)com(dot)au(dot)(dot)(dot)
> 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.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message alvin.yk 2005-04-04 10:32:04 8.0.1 performance question.
Previous Message Chris White (cjwhite) 2005-04-03 22:39:54 Re: JDBC and transactions