Hi I have a difficulty in insertion data. I don't get any error message but it doesn't insert data to database. My code is below. Where am I wrong?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <HR noshade size="5" width="50%" align="center">                
    <title>ZONE</title>
    </head>
    <body bgcolor="Silver">
    
    <%@ page language="java" import = "java.sql.*,java.util.*,java.text.*,java.io.*" %>
   <CENTER>
    <h4><font size="4" face="Verdana">ZONE MASTER</font> </h4>
    <BR></BR>
    <h4><font size="2" face="Verdana">ZONE CODE <input type="text" name="ZONE_CODE" value="" width="06" /> </h4></font>
    <h4><font size="2" face="Verdana">ZONE NAME <input type="text" name="ZONE_NAME" value="" width="06" /> </h4></font>
    </CENTER>
    
    
    <%
                  
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
    Connection con = DriverManager.getConnection("jdbc:odbc:oraclexe","hr","hr");
      
    String zone_code=request.getParameter("ZONE_CODE");
    String zone_name=request.getParameter("ZONE_NAME");
    
    if(request.getParameter("INSERT") != null) {
             try{
     String ins=  "insert into ni_zone_master (zone_code,zone_name  ) values ('"+zone_code+"', '"+zone_name+"')";
  
            PreparedStatement st1 = con.prepareStatement(ins);
	  st1.executeUpdate();
            
           con.close();
         }
         catch(SQLException sqle)
        {
		out.println("ERROR IN PAGE"+sqle);
        }   
    }
    if(request.getParameter("UPDATE") != null) {
               try{
     String ins=  "UPDATE ni_zone_master SET zone_code = '"+zone_code+"', zone_name = '"+zone_name+"' WHERE zone_code = '"+zone_code+"' AND zone_name = '"+zone_name+"' ";
  
           PreparedStatement st1 = con.prepareStatement(ins);
	  st1.executeUpdate();
      
          	
		con.close();
         }
         catch(SQLException sqle)
        {
		out.println("ERROR IN PAGE"+sqle);
        }   
    }
    if(request.getParameter("DELETE") != null)
               try{
     String ins =  "DELETE FROM ni_zone_master WHERE zone_code = '"+zone_code+"' AND zone_name = '"+zone_name+"'";
  
           PreparedStatement st1 = con.prepareStatement(ins);
             st1.executeUpdate();
              con.close();
         }
         catch(SQLException sqle)
        {
		out.println("ERROR IN PAGE"+sqle);
        }   
   
    %>
   
     <CENTER>
    <form name="INSERT" method="POST">
    <input type="submit" value="ADD" name="ADD" onclick="InsertZoneInfo()"/></form>
    <form name="CHANGE" method="POST">   
    <input type="submit" value="UPDATE" name="UPDATE" onclick="UpdateZoneInfo()"/></form>
    <form name="DELETE" method="POST">   
    <input type="submit" value="DELETE" name="DELETE" onclick="DeleteZoneInfo()"/></form>
    </CENTER>
    </body>
    <HR noshade size="5" width="50%" align="center">   
</html>

i'm so sorry as i was very new to this community and now what should i do shall i remove this thread and paste it somewhere else?
and plz do solve my problem. Is my code correct or i should do any modifications?It's very urgent......thanks in advance

Well syntactically your JSP page is correct, although the approach of firing queries directly from inside the JSP page (that too using SQL Statements constructed on the fly) is not only bad but dangerous .

Also you need some brushing up on your concepts of HTML and Javascript. The <input> tags need to be nested inside a corresponding <form> tag, if you want the data from the <input> tag to be posted to the JSP page mentioned in the "action" attribute of <form> tag.
Also I do not see any Javascript functions by the name of InsertZoneInfo(),UpdateZoneInfo() or DeleteZoneInfo()

If you are using Firefox you could go to Tools ->Error Console to see the various Javascript errors or alternatively you could install the Firebug extension for more comprehensive debugging info.
Anyways the situation as I see demands that you learn not only about JSP and MVC[ 1 , 2 , 3 ] but also about HTML and JavaScript right now.

double check on database schema and tables and columns

are they exactly what you have in the code?

You can make two changes:
1: from oracle database homepage login as administrator then unlock the hr (may be it work)
2: try this url: to Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr"); hope this will works.........

bye

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.