Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat JNDI datasource ,where is the managed datasource object?

 
Guogang Fan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When tomcat running,we can get a connection from a datasource .

where the datasource come from?

is that some thread started by tomcat always running ,when web app request a connection ,the thread provide it from it's connection pool?

 
Guogang Fan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we bind a datasource object to a Name within a context,is that means the datasource was converted into byte stream and stored in somewhere?
when we lookup a object by it's Name,is that means we revert the byte stream back to a Object ?

but i saw the tomcat source code ,bindings is just a HashMap .

some one please help me to understand it.

sorry for my poor english.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18218
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat allows you to define resources which will then be cataloged into its JNDI repository. There's a special section of the Tomcat documentation that supplies detailed information on how to define a DataSource resource object in Tomcat.

Tomcat will use this information to construct and initialize the datasource and to publish it in JNDI under the name you supply as part of your datasource definition. For example, if your datasource definition defines that datasource as being named "jdbc/mydatasource", then the web application could make a JNDI lookup request for "java:comp/env/jdbc/mydatasource". This would then return the datasource interface which you would use to acquire connections from the datasource connection pool.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic