Programming Error
import javax.servlet.*;
import java.io.*;
import javax.servlet.http.*;
import java.sql.*;
public class UpdateOrd extends HttpServlet
{
public void doPost(HttpServletRequest req,
HttpServletResponse res) throws ServletException,
IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
int OrderNo2=Integer.parseInt(req.getParameter("OrderNo1"));
String Date2=req.getParameter("Date1");
String Month2=req.getParameter("Month1");
String Year2=req.getParameter("Year1");
String Desig2=req.getParameter("Desig1");
String Qualify2=req.getParameter("Qualify1");
String Status2=req.getParameter("Status1");
String Name2=req.getParameter("Name1");
String Address2=req.getParameter("Address1");
String Email2=req.getParameter("Email1");
String PhoneNo2=req.getParameter("PhoneNo1");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:Advdsn");
Statement s=con.createStatement();
int x=s.executeUpdate("Update OrderTab set Date='"+Date2+"', Month='"+Month2+"', Year='"+Year2+"', Designation='"+Desig2+"', Qualification='"+Qualify2+"', Status='"+Status2+"', Name='"+Name2+"', Address='"+Address2+"', Email='"+Email2+"', PhoneNo='"+PhoneNo2+"' where OrderNo='"+OrderNo2+"'");
if(x>0)
{
out.println("<html><body bgcolor=\"lightblue\">");
out.println("<b><h1>Your order has been Updated</h1></b><br><br>");}
else
out.println("<b><h1>Sorry your order has Not been Updated</h1></b><br><br>");
out.println("<a href=\"http://localhost:8080/ProjectAd/ViewAllOrd\"><b>View<b></a><br><br>");
out.println("<a href=\"http://localhost:8080/ProjectAd/Update.jsp\">Back</a><br><br>");
out.println("<a href=\"http://localhost:8080/ProjectAd/PlaceOrd.jsp\">BackToPlaceOrder</a>");
out.println("</body></html>");
}
catch(SQLException se)
{
out.println(se.getMessage());
}
catch(Exception e)
{
out.println(e.toString());
}
}
public void doGet(HttpServletRequest req,
HttpServletResponse res) throws ServletException,
IOException
{doPost(req,res);}
}
Database Fields are:
OrderNo=Primary Key
Date
Month
Year
Designation
Qualification
Status=Open,Closed,Cancelled,Working
Name
Address
Email
PhoneNo
There some problem in update statement its not getting updated what to do ??
And i want to validate phone number field in which i can add only 8 digits or 10 digits only then how to validate??
Please reply me??
Thankyou Sir .
View Answers
February 2, 2010 at 2:54 PM
Hi Friend,
1) Change your field name Date to Day as it contradicts and try the following code:
import javax.servlet.*;
import java.io.*;
import javax.servlet.http.*;
import java.sql.*;
public class UpdOrders extends HttpServlet{
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String OrderNo2=req.getParameter("OrderNo1");
String Date2=req.getParameter("Date1");
String Month2=req.getParameter("Month1");
String Year2=req.getParameter("Year1");
String Desig2=req.getParameter("Desig1");
String Qualify2=req.getParameter("Qualify1");
String Status2=req.getParameter("Status1");
String Name2=req.getParameter("Name1");
String Address2=req.getParameter("Address1");
String Email2=req.getParameter("Email1");
String PhoneNo2=req.getParameter("PhoneNo1");
int ono=Integer.parseInt(OrderNo2);
int date=Integer.parseInt(Date2);
int month=Integer.parseInt(Month2);
int year=Integer.parseInt(Year2);
int no=Integer.parseInt(PhoneNo2);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:access");
Statement s=con.createStatement();
int x=s.executeUpdate("update OrderTab set Day="+date+",Month="+month+",Year="+year+", Designation='"+Desig2+"', Qualification='"+Qualify2+"', Status='"+Status2+"', Name='"+Name2+"', Address='"+Address2+"', Email='"+Email2+"', PhoneNo="+no+" where OrderNo="+ono+"");
if(x>0)
{
out.println("<html><body bgcolor=\"lightblue\">");
out.println("<b><h1>Your order has been Updated</h1></b><br><br>");}
else{
out.println("<b><h1>Sorry your order has Not been Updated</h1></b><br><br>");
out.println("<a href=\"
http://localhost:8080/ProjectAd/ViewAllOrd\"><b>View<b></a><br><br>";);
out.println("<a href=\"
http://localhost:8080/ProjectAd/Update.jsp\">Back</a><br><br>";);
out.println("<a href=\"
http://localhost:8080/ProjectAd/PlaceOrd.jsp\">BackToPlaceOrder</a>";);
out.println("</body></html>");
}
}
catch(Exception se)
{
out.println(se);
System.out.println(se);
}
}
public void doGet(HttpServletRequest req,
HttpServletResponse res) throws ServletException,
IOException
{doPost(req,res);}
}
2)Phone Number Validation:
<script>
function checkPhoneNo(num){
if(isNaN(num)){alert("Invalid Phone Number. The only characters permitted are 0 to 9"); return 0;}
else{return 1;}
}
function validate(){
var pno=document.form.PhoneNo1;
if ((pno.value==null)||(pno.value=="")){
alert("Please Enter your Phone Number")
pno.focus()
return false;
}
if (checkPhoneNo(pno.value)==false){
pno.value=""
pno.focus()
return false;
}
if ((pno.value.length==8)||(pno.value.length==10)){
return true;
}
else{
alert("Phone Number must be of 8 numbers or 10 numbers");
return false;
}
return true;
}
</script>
Thanks
Related Tutorials/Questions & Answers:
programming errorprogramming error I got an
error when i did the following program
the prg. is to "select the name from database when the age is given for the respective name"
error i got is:SQL exception
please give me the solution by providing
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
Advertisements
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
error at programmingerror at programming import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res
error at programmingerror at programming <p>import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;</p>
<p>public class Login extends HttpServlet
{
public void doPost(HttpServletRequest
Programming Error - JSP-ServletProgramming Error Hello Sir,
how to convert a txt written in textarea of html must get converted to integers and should get displayed... integer.parseInt but its giving
error.
Please Reply me .
Thank you
Programming Error - JSP-ServletProgramming Error
Place Ad
function funct(){
if(document.form.DraftAd.value=="" || document.form.DraftAd.value==null... ??? And when i tried its giving me
error than cannot find variable.In
Programming Error - JSP-ServletProgramming Error Hello Sir,
import java.util.*;
import...();
}
}
}//End of class
m geeting
error in this can u please tell me whats the
error nd how to solve
Programming error - JDBCProgramming error import javax.servlet.*;
import...)
{
out.println("Database
Error :"+se.getMessage());
}
catch(Exception e)
{
out.println(e.toString());
}
}
}
Please reply me the
error in this program because i
programming error - Java Beginnersprogramming error how can we statically implement linked list???????? Hi Friend,
Please visit the following links:
http://www.roseindia.net/java/jdk6/LinkedListExample.shtml
http://www.roseindia.net/java
Programming error - JSP-ServletProgramming error Actually there is an
error in placeorder.jsp file where there are 5 fields OrderNo ,Name , Address, Email, PhoneNo
where if I delete an order of client based on orderno then suppose in database if there are 5
Programming Error - JSP-ServletProgramming Error
Place Order
function checkName...("");
}
catch(SQLException se)
{
out.println("Database
Error :"+se.getMessage());
}
catch(Exception e)
{
out.println("General
Error :"+e.getMessage
Programming error - JSP-ServletProgramming error Register.jsp
Registration...");
}
catch(SQLException se)
{
out.println("Database
Error :"+se.getMessage());
}
catch(Exception e)
{
out.println("General
Error :"+e.getMessage());
}
%>
programming error - Java Beginnersprogramming error import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Place_Ad extends...(SQLException se)
{
out.println("Database
Error :"+se.getMessage());
}
catch(Exception e
programming error - Java Beginnersprogramming error What is
error in this page and how to use RequestDispatcher in servlet to validate it please do reply??
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import
Programming error - JSP-ServletProgramming error
--%>
Place Order
function Validate()
{
var valid=true;
if(document.forms.OrderNo.value=="")
{ alert... where if @ is not given or (dot). is not given etc then it should display
error Programming error - JSP-ServletProgramming error Hello Sir,
Can u please reply me the code for javamail please actually i watch the javamail.net but i dint understood it.
Actually i want to send a mail to my clients with a small text message.
Please
Programming Error - JSP-ServletProgramming Error Image:
I want that when user clicks on browse button then a folder of images should get open and when user clicks one image from it (only one not more than that)then it should get displayed on next page
Programming Error - JSP-ServletProgramming Error
Place Ad
function funct(){
if(document.form.DraftAd.value=="" || document.form.DraftAd.value==null)
{
document.form.cnt.value=0;}
else
{document.form.cnt.value
Programming Error - JSP-ServletProgramming Error
Payment
Advertisement Management System
Payment
Premium Position
FrontPage
BackPage
Other Premium Pages
Page 2
Page 3
Page 5
Page 7
Total Cost:
How to use switch
Programming Error - JSP-ServletProgramming Error Image:
Browse
When user clicks on Browse Button then a folder of images should get open and when user clicks one of them then the path of that should get saved in Access Database and on next page
Programming error - JSP-ServletProgramming error
Payment
Advertisement Management System
Payment
Premium Position
FrontPage
BackPage
Other Premium Pages
Page 2
Page 3
Page 5
Page 7
Total Cost:
I want that the no of characters
Programming Error - JSP-ServletProgramming Error
function Draft()
{
if(document.form.Count.value==""||document.form.Count.value==null)
document.form.Count.value=0;
else
document.form.Count.value = document.form.DraftAd.value.split(' ').length
Programming Error - JSP-ServletProgramming Error How to validate login page using jsp where it checks for username whether it is empty or not or is it including number or not if it is the paste alert message.
Hi Friend,
Try the following
Programming Error - JSP-ServletProgramming Error
Place Ad
Advertisement Management System
Create Ad
State:
City:
Main Category:
Sub Category:
Title:
Draft Your Ad Here
Programming Error - JSP-ServletProgramming Error Ya States and cities and maincategory and subcategory are combobox and maincategory contains suppose matrimonial then sub category will contain groom and bride,
if main category contains vehicals then sub
Programming Error - JSP-ServletProgramming Error
MainPage
body
{
font-family:arial,helvitica,serif;
color:purple;
background-color:#717D7D;
}
ul
{
list-style-type:none;
margin:0;
padding:4px;
}
li
{
list-style-type:none;
padding
Programming Error - JSP-ServletProgramming Error Domain Table:--
Rfcdkey DomainName DomainValue DepDomainValue Statcd
1 StateCd Maharashtra Mumbai A
2 StateCd Maharashtra Pune A
3 StateCd Maharashtra Nashik A
4
Programming Error - JSP-ServletProgramming Error Place.jsp
function func(){
var filename = document.form.img.value;
var st=document.form.State.value;
var ci=document.form.City.value;
var main=document.form.mainCat.value;
var sub
Programming error - JSP-ServletProgramming error
Place Order
function checkName(text)
{
if(isNaN(text)){ return 1;}
else{alert("Invalid Name! The only charachters accepted are A - Z and a - z");return 0;}
}
function checkPhoneNumber
programming error - JSP-Servletprogramming error
Place Order
function Validate()
{
var valid=true;
if(document.forms.OrderNo.value=="")
{ alert("Please enter valid OrderNo");
valid=false;
}
if(document.forms.Name.value
Programming Error - JSP-ServletProgramming Error
Place Ad
Advertisement Management System
State:
City:
Main Category:
Sub Category:
Title:
Draft Your Ad Here:
Count:
Image
Another Image
Email:
Phone No:
Select Newspaper
Programming Error - JSP-ServletProgramming Error import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendMail {
public static void main(String args[]) throws Exception {
String host = "192.168.10.205
Programming Error - JSP-ServletProgramming Error
Place Ad
function func()
{
var filename = document.form.img.value;
window.location.href=("http://localhost:8080/ProjectAd/Preview?
filename="+filename);
}
function Draft
Programming error - Java BeginnersProgramming error import javax.servlet.RequestDispatcher;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ModuleServlet extends HttpServlet {
public void doGet(HttpServletRequest
Programming error - JSP-ServletProgramming error Place.jsp code
function func(){
var filename = document.form.img.value;
var st=document.form.State.value;
var ci=document.form.City.value;
var main=document.form.mainCat.value;
var sub
Programming Error - JSP-ServletProgramming Error import javax.servlet.*;
import java.io.*;
import javax.servlet.http.*;
import java.sql.*;
public class UpdateOrd extends HttpServlet
{
public void doPost(HttpServletRequest req,
HttpServletResponse
ProgrammingProgramming Given a number n, write a
programming to determine its square root if it is possible, in the contraly case print an appropriate massege on the screen
programming Java Constructor
programming for single and double constructor write a program which have no argument constructor ,single parameter constructor constructor,double parameter constor,and the now when we create a object
errorerror while iam compiling iam getting expected
error Error- Error- Hello, I would like to know about XSD file.
I try to print XML file but I am getting
error SAXException-- says
Content is not allowed in prolog.
Please help me
errorerror i have 404
error in my program plz tell me yhe solution about
errorerror i have 404
error in my program plz tell me yhe solution about
error/ServletUserEnquiryForm.shtml
getting an
error given below
SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax
error
please suggest
ErrorError I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me
error as 'Unknown Runtime
Error'.
This
error come only in IE browser, but in other brower