This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes JDBC and the fly likes DataSource.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DataSource...." Watch "DataSource...." New topic
Author

DataSource....

Suresh Selvaraj
Ranch Hand

Joined: Nov 14, 2000
Posts: 104
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


Suresh Selvaraj, (author of JQuiz)<br />SCJP2<br /><a href="http://www.decontconsulting.com" target="_blank" rel="nofollow">www.decontconsulting.com</a>
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
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

Joined: Oct 19, 2001
Posts: 24
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

Joined: Nov 14, 2000
Posts: 104
Thanks SAF and Naveen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataSource....