I suggest not involving Struts at all when it comes to configuration of and access to data stores.
Write a ConnectionManager (sounds like you've already got that idea), who will be in charge of Connections. In the ConnectionManager's init block or constructor, look up your DataSource using a JNDI lookup based on the name you used in your container's DataSource configuration file (in Tomcat this would typically be your "context.xml" file, which is often called "<my_app_name>.xml"), and cache the reference to the DataSource. Then provide a static method (or a instance method on a singleton) for getting connections. (Please note I didn't proofread this for errors) DataSource ds; . . . InitialContext ic = new InitialContext(); Object o = ic.lookup("java:/comp/env/jdbc/MyDataSource");// "MyDataSource" was specified in Tomcat file, "foo.xml" ds = (DataSource) PortableRemoteObject.narrow(DataSource.class, o); . . . static getConnection() { try { return ds.getConnection(); } catch (Exception e) { //try using DriverManager } return null; } You probably already know all this, it's the same old fashioned J2EE way . . . Erik -----Original Message----- From: Vijay K Anand <[EMAIL PROTECTED]> Sent: Jul 8, 2005 3:47 AM To: Struts Users Mailing List <user@struts.apache.org> Subject: Database Connection Hi All I have a helper class which does creating connection and exception handling for that . How do i create connection like DataSource dataSource = (DataSource)context.getAttribute(Action.DATA_SOURCE_KEY) ; objConnection = datasource.getConnection(); it says error at context and Action.DATA_SOURCE_KEY Any help brothers? --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]