take a look a the log file localhost_log.txt
perhaps there is a startup failure when reading out the struts-config.xml
file which prevents struts from loading the db correctly.
verify also the classpath settings for the db jar files
(mm.mysql-2.0.4-bin.jar and jdbc2_0-stdext.jar )


-----Ursprüngliche Nachricht-----
Von: Bradley Cowen [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 21. August 2001 01:36
An: [EMAIL PROTECTED]
Betreff: RE: cannot find the datasource in struts?


I can show you an example of what i'm using (MySQL):

In struts-config.xml:

  <data-sources>
    <data-source>
      <set-property property="autoCommit"
                     value="false"/>
      <set-property property="description"
                     value="MySQL"/>
      <set-property property="driverClass"
                     value="org.gjt.mm.mysql.Driver"/>
      <set-property property="maxCount"
                     value="4"/>
      <set-property property="minCount"
                     value="2"/>
      <set-property property="password"
                     value="pass"/>
      <set-property property="url"
                     value="jdbc:mysql://localhost:3306/test"/>
      <set-property property="user"
                     value="servlet"/>
    </data-source>
  </data-sources>

Then, you can set up a TestAction.java action class with a perform method
like this:

public final class TestAction extends Action {
    public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
                                 HttpServletResponse response)
            throws IOException, ServletException {
        Connection connection = null;
        DataSource dataSource = null;
        Statement statement = null;
        ResultSet resultSet = null;

        try {
            dataSource = servlet.findDataSource(null);
            connection = dataSource.getConnection();

            statement = connection.createStatement();
            resultSet = statement.executeQuery("SELECT FirstName,LastName
FROM People "
                    + "ORDER BY LastName,FirstName");
            resultSet.close(); // just a test
        } catch (SQLException sqle) {
            getServlet().log("Connection.process", sqle);
        } finally {

            //always close connection
            try {
                connection.close();
            } catch (SQLException e) {
                getServlet().log("Connection.close", e);
            }
        }

        // Forward control to the specified success URI
        return (mapping.findForward("success"));
    }
} // end TestAction

HTH,

-Brad

-----Original Message-----
From: Manish Pandya [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 20, 2001 3:06 PM
To: [EMAIL PROTECTED]
Subject: cannot find the datasource in struts?


a newbie in using struts...
kindly let me know what i should be doing to define a datasource..
i have the struts-config.xml file where i defined the datasource
parameters...
and now i m trying to run the example provided in the struts....
but it is throwing error javax.sql.DataSource not found...

is there anything that i m missing? let me know please...

Reply via email to