pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedDataSource lookup
3+ messages / 2 participants
[nested] [flat]
* DataSource lookup
@ 2005-04-03 09:33 Nico <nicohmail-postgresql@yahoo.com>
2005-04-03 20:54 ` Re: DataSource lookup luke@chipcity.com.au
0 siblings, 1 reply; 3+ messages in thread
From: Nico @ 2005-04-03 09:33 UTC (permalink / raw)
To: pgsql-jdbc
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.
Kind regards,
Nico.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: DataSource lookup
2005-04-03 09:33 DataSource lookup Nico <nicohmail-postgresql@yahoo.com>
@ 2005-04-03 20:54 ` luke@chipcity.com.au
2005-04-04 09:00 ` Re: DataSource lookup Nico <nicohmail-postgresql@yahoo.com>
0 siblings, 1 reply; 3+ messages in thread
From: luke@chipcity.com.au @ 2005-04-03 20:54 UTC (permalink / raw)
To: pgsql-jdbc
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: DataSource lookup
2005-04-03 09:33 DataSource lookup Nico <nicohmail-postgresql@yahoo.com>
2005-04-03 20:54 ` Re: DataSource lookup luke@chipcity.com.au
@ 2005-04-04 09:00 ` Nico <nicohmail-postgresql@yahoo.com>
0 siblings, 0 replies; 3+ messages in thread
From: Nico @ 2005-04-04 09:00 UTC (permalink / raw)
To: pgsql-jdbc
Thanks a lot, gonna try it out right away...
Nico.
<luke@chipcity.com.au> schreef in bericht
news:20050403205435.GB1806@bench.chipcity.com.au...
> 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
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-04-04 09:00 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-04-03 09:33 DataSource lookup Nico <nicohmail-postgresql@yahoo.com>
2005-04-03 20:54 ` luke@chipcity.com.au
2005-04-04 09:00 ` Nico <nicohmail-postgresql@yahoo.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