Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

What is JNDI datasource in spring

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
Rohit Bajaj
Asked:
Rohit Bajaj
1 Solution
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now