Solved

What is JNDI datasource in spring

Posted on 2016-09-29
1
110 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 36

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

617 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