thanQ for the reply
previously i exceuted like that only
after that i moved to jsp
here i got some errors
now i solved my problem from the forum
But now i am getting the logical errors
when ever i am inserting the data(either new user,or existing user) its giving same msg
and its not storing the new user in data base
here my code is
validate.jsp
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page contentType="text/html" %>
<html>
<body>
<%
String uname=(String)request.getParameter("uname");
String pwd=(String)request.getParameter("pwd");
String age=(String)request.getParameter("age");
String email=(String)request.getParameter("pwd");
int age1=Integer.parseInt(age);
if(!isUserExists())
{
try
{
%>
<h1><%=uname%></h1>
<h1><%=pwd%></h1>
<h1><%=age%></h1>
<h1><%=email%></h1>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","SYSTEM","remora");
System.out.println("connceted----->"+con.getClass());
String vsql="insert into app_users values(?,?,?,?)";
PreparedStatement psmt=con.prepareStatement(vsql);
psmt.setString(1,uname);
psmt.setString(2, pwd);
psmt.setInt(3,age1);
psmt.setString(4,email);
psmt.executeUpdate();
con.close();
%>
<jsp:forward page="/success.jsp"/>
<%
}
catch(Exception e)
{
System.out.println("Exception"+e);
}
}
else
{
%>
<jsp:forward page="/failure.jsp"/>
<%
}
%>
<%!
public boolean isUserExists()
{
int count=0;
String uname="geeta";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","SYSTEM","remora");
System.out.println("connceted----->"+con.getClass());
Statement stmt=con.createStatement();
String vsql="select count(1) from app_users where uname='"+uname+"'";
ResultSet rs=stmt.executeQuery(vsql);
while(rs.next())
{
count = rs.getInt(1);
}
con.close();
}
catch(Exception e)
{
System.out.println("Exception ..."+e);
}
if(count==0)
return false;
else
return true;
}
%>
</body>
</html>
this is the code to validate wheather user existed or not
can you find where was i did the mistake
how to change the code
Thanks and Regards
Geeta