Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataSource....

 
Suresh Selvaraj
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can anyone explain me on what happens when we use the following.
For Example;
InitialContext icx = new InitialContext();
DataSource ds = (DataSource)icx.lookup(collo/apps);
I'd like to know how and where the "collo/apps" is registered.
Any example on how and where to register?
Thanks,
Suresh Selvaraj
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you can "look up" an object, you must first bind the object to a context.
MyDataSource dataSource = new MyDataSource();
Contex c = new InitialContext();
context.bind( "collo/apps", dataSource);
In the above lines, we created a data source, which represents your connection pool, then we created an IntitialContext so we could "bind" the object to an alias -- in this case "collo/apps" -- using JNDI.
The data source is now available to anyone, even applications running on remote machines. It should matter to you "where" the object is stored, because it could be stored on a remote machine.
Hope that helps...
SAF
 
Naveen Kuppili
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is actually better that you do this declaratively using the tool provided by your vendor rather than programmatically. For example with iPlanet, you can use "dsreg" to register a datasource. This way it is much easier to specify the driver details, max number of connections, etc.
Unless there is a strong reason to do it programmatically, this is the preferred way of registering a datasource.

[This message has been edited by Naveen Kuppili (edited November 27, 2001).]
 
Suresh Selvaraj
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks SAF and Naveen.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic