i tried evry thing possibly i can... still its not working.. plz dont get angry .. iam a student we r doing a project for this i have to do this..plz help me in this...iam sending my total code..
SearchServlet:
____________
package com;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SearchServlet extends HttpServlet
{
private ServletConfig config;
public void init(ServletConfig config)
throws ServletException{
this.config=config;
}
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
PrintWriter out = response.getWriter();
String connectionURL = "jdbc:mysql://localhost/basha";
Connection connection=null;
ResultSet rs;
String mobileno=request.getParameter("mno");
String password=request.getParameter("pwd");
response.setContentType("text/html");
HttpSession ses=request.getSession(true);
try {
// Load the database driver
Class.forName("com.mysql.jdbc.Driver");
// Get a Connection to the database
connection = DriverManager.getConnection(connectionURL, "root", "3ptec");
//Add the data into the database
String sql = "select mobileno,password from newuser where mobileno='"+ mobileno + "'and password='"+ password + "' " ;
Statement s = connection.createStatement();
rs=s.executeQuery (sql);
rs = s.getResultSet();
while (rs.next ())
{
mobileno=rs.getString("mobileno");
password=rs.getString("password");
out.println("MOBILENO=" +mobileno );
out.println("PASSWORD=" +password );
}
rs.close ();
s.close ();
}
catch(Exception e)
{
System.out.println("Exception is ;"+e);
}
if(mobileno.equals(request.getParameter("mno")) && password.equals(request.getParameter("pwd")))
{
out.print("You are Already Registerd ");
}
else
{
out.println("You are not a Valid User Please Register");
out.println("
Register Here!!");
}
}
}
search.jsp
----------------
<%@ page language="java" %>
Login
Please enter MobileNumber and password
MobileNo :
Password :
Newuser
Signup
table
---------
mysql> create table newuser(mobileno char(20),password char(20));
Query OK, 0 rows affected (0.08 sec)
mysql> insert into newuser values('9999999999','Peter');
Query OK, 1 row affected (0.03 sec)
where iam doing the mistake?.......................
If you would just merge my query with your code wouldn't it do the same or you need me to spoon feed you the exact java syntax, then here it is :-
String sql = "select password from newuser where mobileno=" + mobileno;