Tue Oct 21, 2008 8:08 pm
<html>
<head>
<title>Sign Up</title>
</head>
<body>
<%@ page language="java" import="java.sql.*" %>
<%
Connection conn;
conn=null;
ResultSet rs;
rs=null;
String empID=request.getParameter("empID");
String pwd1=request.getParameter("pwd1");
String pwd2=request.getParameter("pwd2");
int flag=0;
String driver="org.apache.derby.jdbc.ClientDriver";
String dbName="assetsdb";
String
connURL="jdbc:derby://localhost:1527/"+dbName+";create=true";
String selQuery="SELECT * FROM Employees where ID=?";
String inQuery="INSERT INTO Viewers values(?,?)";
try
{
Class.forName(driver);
conn=DriverManager.getConnection(connURL);
PreparedStatement stat=conn.prepareStatement
(selQuery);
stat.setString(1,empID);
rs=stat.executeQuery();
if(!rs.next())
{
flag=1;
%>
<script type="text/javascript">
alert("Employee ID Not Found.");
location.href="NewViewer.htm";
</script>
<%
conn.close();
}
}
catch(Exception e)
{
out.println("Mistake:"+e);
}
if(flag==0)
{
try
{
Class.forName(driver);
conn=DriverManager.getConnection(connURL);
PreparedStatement stat1=conn.prepareStatement
(inQuery);
stat1.setString(1,empID);
stat1.setString(2,pwd1);
stat1.executeUpdate();
flag=0;
response.sendRedirect("login.htm");
}
catch(Exception e)
{
out.println("Mistake inserting values:"+e);
}
finally
{
rs.close();
conn.close();
}
}
%>
</body>
</html>
Tue Oct 21, 2008 8:09 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.