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
likeyou 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.