You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by DwarfInLeopardSkin <dw...@ntlworld.com> on 2003/06/24 18:54:55 UTC

Problems with database connectivity: DATA_SOURCE is not bound in this Context

I'm building an application for a University project. I've created a plugin:

public class ConnectionAdaptorPlugin implements PlugIn {

private ModuleConfig config = null;
private ActionServlet servlet = null;

private static Log log = LogFactory.getLog(ConnectionAdaptorPlugin.class);

public static final String INITIALISATION_ERROR = "Connection pool not
available.";

private static ConnectionAdaptor adaptor = null;

private static String
    adaptorClass = "org.apache.commons.scaffold.sql.ConnectionAdaptor";


public ConnectionAdaptorPlugin() {
}

public void init(ActionServlet servlet, ModuleConfig config)
  throws ServletException {

  try {
       adaptor =
(ConnectionAdaptor)Class.forName(adaptorClass).newInstance();
      }

      catch (Throwable t) {
       log.fatal(INITIALISATION_ERROR,t);
       throw new ServletException(t);
 }

 log.info("ConnectionAdaptor plug-in initialised");

}

public void destroy() {
 adaptor = null;
 log.info("ConnectionAdaptor plug-in destroyed");
}

}


It _should_ instantiate a Scaffold ConnectionAdaptor, making it available
for other Scaffold classes such as StatementUtils. I have another class
representing the database that calls methods in Scaffold's StatementUtils
class to retrieve data from, and update data in the database. I consistently
get this error message, which I don't understand:

DATA_SOURCE is not bound in this Context

DATA_SOURCE should be available?

As a test/experiment I tried using the database connection example given in
the Struts documentation - where the Action retrieves a connection object
and passes it on to the next layer. This gave an error along the lines of
"user SNEEZY not found". Sneezy is my nickname but I haven't used it in any
configuration file and I haven't been able to find it in any configuration
file!

I have this data source setup in struts-config:

<data-source type="org.apache.commons.dbcp.BasicDataSource">
     <set-property property="defaultAutoCommit" value="false"/>
     <set-property property="description" value="Pointbase Connection"/>
     <set-property property="driverClassName"
value="com.pointbase.jdbc.jdbcUniversalDriver"/>
     <set-property property="password" value="xxxxx"/>
     <set-property property="url"
value="jdbc:pointbase://localhost:9092/resources"/>
     <set-property property="user" value="xxxxx"/>
   </data-source>

I'm developing on my home PC (Windows 98SE) using the Sun One/Forte IDE and
the freebie Pointbase database (I don't have access to any other).

Any help would be appreciated.

Thanks

John




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org