This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
A datasource is typically a way for the server to manage the connection (or more likely connection pool) for you. A server has a map of datasources and other managed resources in a directory called the JNDI. You use a JNDI reference name in order to retrieve a reference to the datasource in your code.
Jeanne Boyarsky wrote:A datasource is typically a way for the server to manage the connection (or more likely connection pool) for you. A server has a map of datasources and other managed resources in a directory called the JNDI. You use a JNDI reference name in order to retrieve a reference to the datasource in your code.
JDBC API is for Database vendor to implement it in their driver classes and Programmer to use it abstractly.
Say for instance, when we define one data source in Application Server, we provide URL, Driver class, Transaction Attribute, Application server on which we want to deploy, properties like user=scott, passowrd=tiger etc.
When we add data source to App server, we provide JNDI name to it. So, application server bound an instance of this data source object (Actually implementation is provided by Database vendor) it.
All interfaces implementation are depends on Driver we selected, interfaces like, DataSource, Connection, Statement, ResultSet etc.
So, when we want to interact with database, we will look-up for the JNDI name we have provided at creation time.
Joined: Nov 04, 2010
Mandy, thanks for the info..
So, in case of connection pooling, application server is responsible to manage the number of logical connections in pool over single physical connection to DB and this is where performance matters.. right?
Or are same number of physical connections maintained between application server & DB as mentioned in pool config?
I am a little curious to know about the generic concept used for implementation, are there any references explaining it?
Joined: Nov 13, 2011
While defining a DataSource, we provice minimum/maximum/unused no of connections we need from datasource. Indirectly it means, it will Application Server manager logical connections internally within.
When we ask datasource to give connection, it will pick up from logical connection pool and provide to you, while physical connection to DB server may remains one.