please someone tell me why this code is failed on testing:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.sql.DataSource;
@WebService()
public class Login {
@Resource(name = "dataproject")
private DataSource dataproject;
/**
* Web service operation
*/
@WebMethod(operationName = "Select")
public String Select(@WebParam(name = "uname")
String uname, @WebParam(name = "passwd")
String passwd) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/project",
"root", "1234");
PreparedStatement st =
con.prepareStatement("select * from user where username='"+uname+"' and password='"+passwd+"'");
ResultSet rs=st.executeQuery();
int rowCount=rs.getRow();
if(rowCount==0) return "Username and or password is not correct!";
else return "connected!";
} catch (Exception e) {
System.out.println(e.getMessage());
}
//TODO write your implementation code here:
return "Username and or password is not correct!";
}
}