Title: Message
if i'm understanding your question properly, you define all the database information in a datasource file which is then placed in
the your deployment directory. (see docs/examples/jca for example data sources)
 
when jboss starts up, it reads the datasource and builds the appropriate connections. if you need to retreive one of those
datasources, you would use the following code:
 
...
Context ctx = new InitialContext();
dataSource = (DataSource) ctx.lookup(dataSourceName)
 
where dataSourceName is the jndi name you specificed in the datasource deployment xml file.
 
as for the intial context factory class, you can just specify the following in a jndi.properties file that is included w/ your jar:
 
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url="">

-jae

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bret Kumler
Sent: Tuesday, January 13, 2004 4:51 PM
To: Jboss
Subject: [JBoss-user] JNDI question

I was wonder, with the default installation of JBOSS, what is the jndi factory lookup for a datasource, the url, username and the password.
 
 
 
E.G. for Weblogic:
 
 private Context getInitialContext(){
 
   Properties properties = null;
   Context ctx =null;
   String weblogic_url="t3://localhost:7001";
   String weblogic_jndi_factory_name="weblogic.jndi.WLInitialContextFactory";
   String user="system";
   String pass="password";

   try {
     properties = new Properties();
     properties.put(Context.INITIAL_CONTEXT_FACTORY, weblogic_jndi_factory_name);
     properties.put(Context.PROVIDER_URL, weblogic_url);
     if (user != null) {
       properties.put(Context.SECURITY_PRINCIPAL, user);
       properties.put(Context.SECURITY_CREDENTIALS, pass == null ? "" : pass);
     }
     ctx= new InitialContext(properties);
   }
   catch (javax.naming.NamingException e) {
     logger.error("Unable to connect to WebLogic server at " + weblogic_url);
   }
   return ctx;
 }
 
 
Thanks
 
 

Reply via email to