Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get the DB URL string using Sybase JNDI/LDAP?

8 views
Skip to first unread message

Snootus...@gmail.com

unread,
Apr 1, 2008, 10:49:56 PM4/1/08
to
I'm new to Sybase/JConnect, and would appreciate some help.
I'm sure what I want to do is very simple, though I can't seem to get
my mind around it.

I need to write Java code to dynamically (at run time), look up the
complete URL string of a DB using Sybase JNDI/LDAP. Here's what I have
so far:
SybDataSource dataSource = new SybDataSource() ;
Properties props = new Properties();
props.put(Context.OBJECT_FACTORIES,
"com.sybase.jdbc2.jdbc.SybObjectFactory");
props.put(Context.PROVIDER_URL, "ldap://
sybaseldap.usa.company.net:4897/dc=sybase,dc=company,dc=com");
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");

try
{
Context ctx = new InitialContext(props);
dataSource = (SybDataSource)
ctx.lookup("sybaseServername=SERVERNAME");
}
catch (Exception e)
{
return;
}

System.out.print("DataSource reference obtained.\n");

Question is, now what? From this, how do I get the complete URL of the
DB? I need the DB URL to pass to another Java program that's making
the JDBC connection.

Apologies for the dumb question.
TIA.

-sm

0 new messages