Solved

What is JNDI datasource in spring

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 65
MySqlDump not dumping triggers 1 43
jboss 7.1 start up error 1 41
Java syntax, or is it Selenium 6 30
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…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

828 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