This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Data source  RSS feed

 
Nischal Topno
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. What is a datasource (i presume it's a factory of connections - just wanted to confirm though)
2. if we do a connection.close() on the connection object we get from the dataSource.getConnection(), does it closes the connection or does it returns the connection to the pool? Logically it should return to the pool.

Nischal
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nischal Topno:
1. What is a datasource (i presume it's a factory of connections - just wanted to confirm though)
2. if we do a connection.close() on the connection object we get from the dataSource.getConnection(), does it closes the connection or does it returns the connection to the pool? Logically it should return to the pool.

Nischal


1. You are correct on what a datasource is. A datasource is simple a container managed connection pool (on most containers) that manages the connections between the container and the data source(database, xml, text etc..)
2. This feature varies depending on the vendor implementation but on most containers when you call the .close() method on the connection object it returns the connections back to the pool and waits for the next .getConnection() method to be called.

Didn't really help much but I hope I at least clarified your already correct thoughts.
[ November 22, 2004: Message edited by: Sloan Bowman ]
 
aitor alzola
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
googling=> http://java.sun.com/j2se/1.4.2/docs/api/javax/sql/DataSource.html A brief explanation.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if we do a connection.close() on the connection object we get from the dataSource.getConnection(), does it closes the connection or does it returns the connection to the pool? Logically it should return to the pool.


Yes, it is returned to the pool. Check the JDBC spec for how the connection pooling could be implemented.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!