Hi I have written an action class for
struts 2.0 but I am getting a compiler errror which says:
missing return statement
[javac] }
[javac] ^
[javac] 1 error
Actually the thing is that I cant change how the class is written.
I am posting the code. Any suggestions are welcome:
package net.astralpharma;
import com.opensymphony.xwork2.ActionSupport;
import java.sql.*;
import java.util.Date;
public class Login extends ActionSupport {
public
String execute()throws Exception
{
String x = getUsername();
String url = "jdbc:mysql://localhost:3306/";
String dbname="astraldb";
String driverName="org.gjt.mm.mysql.Driver";
String userName="root";
String password="root";
Connection con=null;
PreparedStatement stat =null;
try
{
Class.forName(driverName);
System.out.println("Driver Loaded");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/astraldb","root","root" );
System.out.println("Database is connected");
String query="Select password from logindet where username=?";
stat = con.prepareStatement(query);
System.out.println(stat);
stat.setString(1, x);
ResultSet rs = stat.executeQuery();
while(rs.next())
{
String pwd_db = rs.getString("password");
System.out.println("database_passwd" + pwd_db);
String pwd_fe = getPassword();
System.out.println("frontend_passwd" + pwd_fe);
if(pwd_db.equals(pwd_fe))
{
return "SUCCESS";
}
else
{
return "ERROR";
}
}
}
catch(SQLException sqle)
{
System.out.println("Exception : " + sqle);
sqle.printStackTrace();
}
catch(Exception e)
{
System.out.println("Exception : " + e);
e.printStackTrace();
}
}
private String username = null;
public String getUsername() {
return username;
}
public void setUsername(String value) {
username = value;
}
private String password = null;
public String getPassword() {
return password;
}
public void setPassword(String value) {
password = value;
}
}