Solved

What is JNDI datasource in spring

Posted on 2016-09-29
1
92 Views
Last Modified: 2016-10-06
HI,
I have come across this term JNDI datasource. What i understand is there are two types of datasources
1) pooled connection
2) unpooled connection
So depending on the application one can use any one of them.

How i have used the databsource is to construct a jdbctemplate from it and then use the jdbc template to query and update the table.
But i dont understand why JNDI is used in front of datasource...
what is JNDI and how is it related to datasource.

Thanks
0
Comment
Question by:Rohit Bajaj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 41827319
But i dont understand why JNDI is used in front of datasource...
what is JNDI and how is it related to datasource.
JNDI is just a "directory" and it can be used to help locate "resources". One of those resources could be a JDBC database connection. So what JNDI can do is move the configuration of your jdbc datasource from within your application so that it can be configured externally.

For example, rather than having to code the JDBC URL and usernames/passwords in your application, you can have your application retrieve the connection from a JNDI implementation such as Tomcat (if your app runs within Tomcat). So you then configure the database parameters in Tomcat and have it publish that as a JNDI resource that you app consumes.


In regards to pooled/non-pooled connections, that doesn't have anything to do with the JNDI part.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question