jndi setup of ldap

K

kevin

hi,

I'm trying to load a Postgresql Jdbc3PooledConnection object into my
openldap server on a redhat box :).

what I wanted was a context jdbc/database, and in that a series of
driver references. I have made an entry, but am not sure I've dont it
right though. Can you see what is wrong?

The examples in the web all have lookups of the form

lookup(jdbc/EmployeeDB)

yet mine won't work unless i use ldap like tags as in

lookup("cn=database,cn=jdbc");

firstly i set up jndi properties to connect to the ldap server. (had
to add write permission on redhat box)

<code>
java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
java.naming.provider.url=ldap://192.168.1.1:389/dc=mtel,dc=co.uk
</code

Then I added the references (had to do this one at a time, modifying
code
lines to add context, then the driver). This i checked with
slapsearch, and
made sure the entries where there. I loaded the driver in a new test
program to make a connection from the driver to test it, so i know it
works.

<code>
Hashtable env = new Hashtable();
Context ctx = new InitialContext();
InitialDirContext dctx = new InitialDirContext();

if(ctx == null )
throw new Exception("JNDI could not create InitalContext
");

//dctx.createSubcontext("cn=jdbc"); ** context 1
//dctx.createSubcontext("cn=database,cn=jdbc"); ** context 2

Jdbc3PoolingDataSource src = new Jdbc3PoolingDataSource(); //
driver
src.setDataSourceName("livedb");
src.setServerName("192.168.254.99");
src.setDatabaseName("livedb");
src.setUser("user1");
src.setPassword("youwish");
src.setMaxConnections(10);

ctx.bind("cn=livetest,cn=database,cn=jdbc", src);

</code>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top