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>