permaculture playing cards*
The moose likes JDBC and the fly likes DataSource and JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DataSource and JNDI" Watch "DataSource and JNDI" New topic
Author

DataSource and JNDI

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Hi,
Can I use the Datasource (ConnectionPoolDataSource) without JNDI?


Groovy
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
You might find the following link helpful for you...
http://sales.esicom.com/sales/oracle/java.816/a81354/samapp9.htm


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
I don't know the answer to Pradeep's question. But if that is possible, can't we use the same approach in every place where we use JNDI?
-Sainudheen
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

JNDI provides you the location transparency.
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Pradeep Bhat:
JNDI provides you the location transparency.

Like it is on your own machine? Just curious...
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Ko Ko Naing:
You might find the following link helpful for you...
http://sales.esicom.com/sales/oracle/java.816/a81354/samapp9.htm

In the document Ko Ko posted a link to, there's this code sample:
What struck me in the eye was that this code doesn't specify where the database server is or which database to connect to. Is there some kind of default-to-localhost mechanism in Oracle's JDBC DataSource implementation?
PS. They do have another sample where the server name, port number and database name are explicitly set:


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

What struck me in the eye was that this code doesn't specify where the database server is or which database to connect to. Is there some kind of default-to-localhost mechanism in Oracle's JDBC DataSource implementation?


I dont think so.
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Lasse Koskela, I think they accidently dropped out in the code... The server name, the database, the protocol and the port number are indispensible, if I am not wrong...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataSource and JNDI
 
Similar Threads
null driver class exception
Datasource
JNDI - CMP Factory Connection Binding
Is javax.sql.DataSource a costlier resource like java.sql.Connection?
Websphere - Datasource Connection communication failure