Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Source and Java Beans 1

Status
Not open for further replies.

jetec

Technical User
May 2, 2006
17
US
how can I utilized a Data source from a java bean? Or do i need to redifine my connection within the class?

Thanks
JE
 
You just use JNDI (javax.naming package) :

// Obtain a JNDI javax.naming.Context object
Context ctx = new InitialContext();
// Retrieve a DataSource object using JNDI
DataSource ds = (DataSource)ctx.lookup("java:comp/env/myDSName");

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Thanks sedj! I did not know I could actually do that, i wasn't sure if it was tomcat specific code. As you can tell, i'm new to jsp/java,tomcat.

Thanks!
JE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top