Thanks Bradley,

Actually my problem turned out to be something else.

I didn't know that all the archives in lib dir ( tomcat home or webapp
individual WEB-INF/lib ) needs to have .jar extension to be recognized by
tomcat. I was using java standard sql extension api release 3 from
java.sun.com which had .zip extension.
Tomcat did not pick it up. after renaming it to be .jar from .zip,
everything worked.

Thanks again,

- Manish

-----Original Message-----
From: Bradley Cowen [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 20, 2001 7:36 PM
To: [EMAIL PROTECTED]
Subject: 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