Sir, I am not getting any fault in my code but the code is not executing with the demands which I have.
I just want to insert values into the database using jsp ,execcuteUpdate() is not working. please help me out.
HTML CODE
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="lightgrey">
<form action="addcustomer.jsp" method="POST">
<h3 align="center">CUSTOMER REGISTRATION</h3>
<table border="0" cellspacing="8">
<tr>
<td>Enter Customer ID</td>
<td><input type="text" name="custID" value="" /></td>
</tr>
<tr>
<td>Enter Customer Name</td>
<td><input type="text" name="custName" value="" /></td>
</tr>
<tr>
<td>Enter Customer Address</td>
<td><input type="text" name="custAdd" value="" /></td>
</tr>
<tr>
<td>Enter Customer Mobile</td>
<td><input type="text" name="custMob" value="" /></td>
</tr>
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</table>
</form>
</body>
</html>
JSP CODE
<%--
Document : addcustomer
Created on : Sep 14, 2011, 11:41:34 AM
Author : RAJIB
--%>
<%@page import="java.sql.*" %>
<% Class c = Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String Customer_Id=request.getParameter("CustId");
String Customer_Name=request.getParameter("CustName");
String Customer_Address=request.getParameter("CustAdd");
String Customer_Mobile=request.getParameter("CustMob");
Connection conn = DriverManager.getConnection("jdbc:odbc:inventory","sa","12345");
out.print("hey");
try
{
PreparedStatement ps = conn.prepareStatement("insert into Customer values(?,?,?,?)");
ps.setString(1,Customer_Id);
ps.setString(2,Customer_Name);
ps.setString(3,Customer_Address);
ps.setString(4,Customer_Mobile);
out.print("hey hi");
ps.executeUpdate();
out.println("success");
}
catch(Exception e){}
%>