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){}
%>

Of course you are not getting any errors because you just ignore what ever exception may be catch after try statement. Do e.printStackTrace() and post error messages you getting.
PS: Recommendation, do read JSP database connectivity according to Model View Controller (MVC) Model 2 if you want to learn how to do this stuff better and more secure way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.