Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Tomcat and the fly likes Tomcat JNDI datasource ,where is the managed datasource object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat JNDI datasource ,where is the managed datasource object?" Watch "Tomcat JNDI datasource ,where is the managed datasource object?" New topic
Author

Tomcat JNDI datasource ,where is the managed datasource object?

Guogang Fan
Greenhorn

Joined: Aug 17, 2009
Posts: 7
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

Joined: Aug 17, 2009
Posts: 7
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

Joined: Jun 25, 2001
Posts: 15959
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat JNDI datasource ,where is the managed datasource object?
 
Similar Threads
Problem with EJB 3. Name not bound error
JDBC Exception in JNDI lookup
Charset1104D00000/Cp1252 is not supported by the JVM.
DBCP deadlock on BasicDataSource.getConnection()
Can I get the datasource without referencing the actionServlet???