Solved

What is JNDI datasource in spring

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 73
json format text only 4 65
pairs challenge 5 44
Java Jpanels and Jframe 8 20
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now