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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC,JNDI,DataSource" Watch "JDBC,JNDI,DataSource" New topic


miria joseph

Joined: Dec 06, 2007
Posts: 7


Can anyone explain how these three works together?

Thanks in Advance.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You can define a JDBC datasource in JNDI.
You can use JNDI API do obtain the JDBC datasource in your Java code.
You can use the JDBC datasource to get a connection to the database.
Bebot Arnado

Joined: Feb 04, 2009
Posts: 6
JDBC is slight similar to JNDI because they are both OO Java API. The JNDI is mostly used for accessing a native interface while the JDBC is more on relational database. You can use JDBC without JNDI or you can use both. Based on your question, the JNDI, JDBC and DataSource can be used together for a purpose. Based on my previous project I used bought because it is part of the technical requirements and I implemented it through Web XML and on my other project I used the Spring Configuration.

The JNDI part was stored on WebSphere variable, so I used the JNDI to call it. The datasource is created on the WebSphere DB connection and the JDBC is my driver or connector type. In WebSphere you can use any type of JDBC, but on my project I used JDBC type 2 because I don't need advance features which is on JDBC type 4.

DataSource reference by JDBC and JDBC can be called by JNDI. For simplistic way: JNDI ( JDBC (DATASOURCE)))

This is just my thought.

ReAch yOur GoAl wHile U hAve tImE.
OptImiZe and MaXiMize ResourCes whILe It is sTiLL FrEe
ThInK BeYonD
I agree. Here's the link:
subject: JDBC,JNDI,DataSource
It's not a secret anymore!