aspose file tools*
The moose likes JDBC and the fly likes JDBC: Concept of DataSource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC: Concept of DataSource" Watch "JDBC: Concept of DataSource" New topic
Author

JDBC: Concept of DataSource

Neel Sharma
Greenhorn

Joined: Aug 16, 2011
Posts: 12
Hi All,

I need to know the concept of DataSource in Java-Database connectivity.

I have worked development of on web based applications and while working in my projects we used to have a datasource named "BankingDatasource".

I always use to just fetch the connection object in java file and write SQL query.

But I have done very less of Data base related work.

Hence I need to understand step by step process how JDBC connection , Data Source works through weblogic/ websphere.

How the Data Source is found , if there are many datasources.

Anyone Please guide.

Thanks
Neelam

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31076
    
233

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Neel Sharma
Greenhorn

Joined: Aug 16, 2011
Posts: 12
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.


Thanks Jeanne.
Kalpesh Malbari
Greenhorn

Joined: Nov 04, 2010
Posts: 3
My understanding is that the data source is a single physical connection to DB used by server to maintain multiple logical instances. Can anyone explain the technical basics behind datasource?

TIA
Kalpesh
Mandy Rocks
Greenhorn

Joined: Nov 13, 2011
Posts: 3
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.


Kalpesh Malbari
Greenhorn

Joined: Nov 04, 2010
Posts: 3

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?

Thanks
Kalpesh
Mandy Rocks
Greenhorn

Joined: Nov 13, 2011
Posts: 3
Absolutely right.

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.

Hope, it clarify
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC: Concept of DataSource