Code:
package com; import com.opensymphony.xwork2.ActionSupport; import java.sql.*; /** * <p> Validate a user login. </p> */ public class retrieve extends ActionSupport { public String execute() throws Exception { String url = "jdbc:mysql://localhost:3306/"; String dbName = "login"; String driverName = "com.mysql.jdbc.Driver"; String userName = "root"; String passWord = "12345"; Connection con=null; Statement stmt=null; try{ Class.forName(driverName).newInstance(); con=DriverManager.getConnection(url+dbName, userName, passWord); stmt=con.createStatement(); } catch(Exception e){ System.out.println(e.getMessage()); } String username=getUsername(); String password=getPassword(); stmt = con.createStatement(); int val = stmt.executeQuery("SELECT USERNAME , password FROM employee WHERE username='admin' AND password ='admin' Values ('"+username+"','"+password+"')"); if(val == 0) { return ERROR; } else { return SUCCESS; } } // ---- Username property ---- private String username; public String getUsername() { return username; } private String password; public String getPassword() { return password; } }
Above is my code .. please help me in debugging this ASAP