Struts and database connection

I am new in Struts and I need help to connect to mysql database. The problem is: The requested resource (Servlet action is not available) is not available.

here is my <data-source> in struts-config.xml :

<data-sources>

<data-source type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">

<set-property

property="driverClassName"

value="com.mysql.jdbc.Driver" />

<set-property

property="url"

value="jdbc:mysql://localhost:3306/casopisi?autoReconnect=true" />

<set-property

property="username"

value="root" />

<set-property

property="password"

value="root" />

<set-property

property="maxActive"

value="10" />

<set-property

property="maxWait"

value="5000" />

<set-property

property="defaultAutoCommit"

value="false" />

<set-property

property="defaultReadOnly"

value="false" />

<set-property

property="validationQuery"

value="SELECT COUNT(*) FROM test" />

</data-source>

</data-sources>

is the problem in this or in action class?

public class LogIn extends Action {

private final static String SUCCESS = "success";

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response)

throws Exception {

javax.sql.DataSource dataSource = null;

java.sql.Connection myConnection;

String username = request.getParameter("username");

String password = request.getParameter("password");

try{

ServletContext context = servlet.getServletContext();

DataSource datasource;

myConnection = dataSource.getConnection();

PreparedStatement stmt=(PreparedStatement) myConnection.createStatement();

String query ="SELECT username, password from users where username=? and password=?";

ResultSet RS=stmt.executeQuery(query);

while(RS.next()){

UserActionFormBean UserBean = (UserActionFormBean)form;

UserBean.setUsername(RS.getString("username"));

UserBean.setPassword(RS.getString("password"));

if(UserBean.getUsername().equals(username)){

return mapping.findForward("logedin");

}

}

}catch (SQLException sqle) {

getServlet().log("Connection.process", sqle);

}

return mapping.findForward("fail");

}

}

[2504 byte] By [draganma] at [2007-11-27 8:33:11]
# 1

Where is your action mappings?

<action

path="/myaction"

name="myForm"

scope="session"

input="/WEB-INF/jsp/yourjsp.jsp"

type="com.path.myActionClass" validate="true">

<forward name="success" path="/WEB-INF/jsp/successjsp.jsp" />

</action>

skp71a at 2007-7-12 20:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
here <action input="/index.jsp" name="UserActionFormBean" path="/actions/login" scope="request" type="vets.ip2.beans.LogIn" validate="false"><forward name="fail" path="/fail.jsp"/><forward name="logedin" path="/Uspeh.jsp"/></action>
draganma at 2007-7-12 20:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

What do you have for your "action" attribute of your JSP's "form" element?

In my Struts app, I have set that to the name of the "Action", (e.g.) if my "Action"'s name is "Login" - which is set by the "path" attribute of my ActionMapping - then for my JSP's "form" element's "action" attribute, I specify "Login.do".

In your case, you have it as "actions/login", does this match with what's on your JSP?

chennaia at 2007-7-12 20:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
jsp's form action attribute:<html:form action="/actions/login">I know that but I think that the problem is in struts-config.xml in datasource tags.Somebody has an idea?
draganma at 2007-7-12 20:29:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...