This week's book giveaway is in the
We're giving away four copies of a choice of
"Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac"
and have Joe Kissell on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
get datasource outside action class
Joined: Mar 21, 2007
Nov 26, 2007 20:12:00
Is there any option to get the datasource connection from the non-action class?, where the datasource specified in the struts-config.xml file.
Joined: Sep 27, 2007
Nov 27, 2007 13:12:00
If the class shares the same
as the action class, then yes, no worries. You can just get the reference that way:
Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup("[I]<resource reference>[/I]"); Connection conn = ds.getConnection();
corresponds to the context.xml entry (or server.xml entry)
subject: get datasource outside action class
Struts 1.1 database connection exception
Which approach is correct for getting a connection of database from a business class
Creating datasource in WAS 5
How to Access SevletContext Object in Action Class
Error:cannot find getDataSource(req)
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014