Skip site navigation (1) Skip section navigation (2)

JNDI & Others

From: renyu teng <renyu_teng(at)yahoo(dot)com>
To: postgresql <pgsql-cygwin(at)postgresql(dot)org>
Subject: JNDI & Others
Date: 2001-11-02 22:30:29
Message-ID: 20011102223029.2373.qmail@web20204.mail.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-cygwin
Hi guys,

below is the msg I have searched in the archive files,
and I have similiar questions, and if anyone knows the
anwsers, could you please drop me a mail.

I use MS 2000. 

Actually I am stuck here with the following msg:

set up:java.naming.factory.initial

Hi  Larry Mulcahy. are you still on this list? if yes,
could you please drop me a mail and tell me how to set
up env. so I could use jndi to get the connection.

thanks.
teng



I have continued working on this and have learned some
things I
didn't understand when I asked this question.

I have succeeded in deploying a PostgreSQL DataSource
using the
file system service provider 
(com.sun.jndi.fscontext.RefFSContextFactory, 
http://java.sun.com/products/jndi/serviceproviders.html).
 I have
one small Java application that binds the DataSource
to a name,
then another application can do a lookup on that name,
do a 
getConnection on the DataSource and with that access
the database.

Now, I'd like to do connection pooling.  After poring
over the
archived messages of pgsql-jdbc and looking at the
source code,
I'm having a hard time determining whether it's
possible to do
this (without using some other software like PoolMan,
Protomatter
or Tyrex).  Some of the messages in the mailing list
such as
http://fts.postgresql.org/db/mw/msg.html?mid=75748
suggest that the ConnectionPoolDataSource interface
ought to be
implemented, but I can't find any classes in the
"enterprise" jar 
file or in the source tree that sound like this.

Is ConnectionPoolDataSource implemented?

Larry Mulcahy wrote:
> 
> I'm trying to create a data source as described in
paragraph
> 5.5.1 of the JDBC 2.0 Standard Extension API
>
(http://java.sun.com/products/jdbc/jdbc20.stdext.pdf).
> (Another example: paragraph 3.7.2 "Deploying a Basic
Datasource
> Object" in
http://developer.java.sun.com/developer/Books/JDBCTutorial/).
> 
> My application produces the output,
> 
> java -classpath
>
.:/usr/local/pgsql/share/java/postgresql.jar:/usr/local/java/jdbc2_0-stdext.jar
> Example
> Creating a new Context...
> Binding...
> Bind failed.
> Exception: javax.naming.NoInitialContextException:
Need to specify class
> name in environment or system property, or as an
applet parameter, or in
> an application resource file: 
java.naming.factory.initial
> 
> I found various documentation about different ways
to specify a value
> for java.naming.factory.initial.  You can put it in
> $JAVA_HOME/lib/jndi.properties, you can specify it
on the command line
> with -Djava.naming.factory.initial=..., you can
create an environment
> Hashtable and pass it as one of the arguments to
InitialContext as
> documented at
http://java.sun.com/products/jndi/tutorial/beyond/env/.
> What I can't find is what value to actually give it
for the
> InitialContextFactory.  Am I supposed to write this
myself?
> 
> This seems like a routine common action that people
must do all the
> time, but I can't seem to find good documentation
about how to do it.
> 
> Is there some administration that needs to be done
behind the scenes,
> e.g. starting a JNDI server?
> 
> Code follows:
> 
> import javax.naming.InitialContext;
> import javax.naming.Context;
> import java.util.Hashtable;
> 
> public class Example {
>     public static void main(String args[])
>     {
>         org.postgresql.PostgresqlDataSource ds =
>             new
org.postgresql.PostgresqlDataSource();
>         ds.setServerName("host");
>         ds.setDatabaseName("database");
> 
>         Context ctx = null;
> 
>         System.out.println("Creating a new
Context...");
>         try {
>             ctx = new InitialContext();
>         }
>         catch (Exception e) {
>             System.out.println("Failed to create a
new Context.");
>             System.out.println("Exception: " + e);
>             return;
>         }
> 
>         System.out.println("Binding...");
>         try {
>             ctx.bind("jdbc/database", ds);
>         }
>         catch (Exception e) {
>             System.out.println("Bind failed.");
>             System.out.println("Exception: " + e);
>             return;
>         }
>     }
> }

-- 
	    Larry Mulcahy		lmulcahy(at)qip(dot)qwest(dot)net
			  PGP public key at:
  
http://pgpkeys.mit.edu:11371/pks/lookup?op=get&search=0x2C4C5A03




__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

pgsql-cygwin by date

Next:From: Jason TishlerDate: 2001-11-03 03:59:07
Subject: Re: Problem starting as service.
Previous:From: Dave PageDate: 2001-11-02 21:21:07
Subject: Re: Problems with Windows XP

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group