Hi,
I think you probably shouldn't enclose the values in quotes that you are
inserting as they may be considered as part of the string.They probably
should be sent as
   st.executeUpdate("insert into invoice" + " values (" + i + ","
+ request.getParameter(param)+ ")");
   hope it helps.

Vaijayanthi.


>From: Prasad Moganna Gowda <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>        Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Date: Fri, 7 Jul 2000 12:03:51 -0500
>
>st.executeUpdate("insert into invoice" + " values (i,
>request.getParameter(param)");
>
>For this statement in your code, check whether you are passing the correct
>data type i.e. if the column is expecting number you should be passing
>number,
>if it is expecting date, then date in a correct format and
>if a string then a string enclosed in single quotes.
>
>output your insert sql to a log file and then directly run those sql's at
>the sql prompt. You will have a better idea as to what is going wrong.
>
>- Prasad
>
> > -----Original Message-----
> > From: veena mallya [SMTP:[EMAIL PROTECTED]]
> > Sent: Friday, July 07, 2000 11:33 AM
> > To:   [EMAIL PROTECTED]
> > Subject:
> >
> > hi,
> >
> > am new to servet programming. i have written a servlet and trying to
> > connect
> > it to a database. the program compiles without any errors however the
> > database is not being updated at all. and the server gives a error
>saying
> > invalid parameter number. i have checked the same, but could not make
>out
> > the mistake i would have made. can you help me please?????? am giving
>the
> > doPost method that i have written in my servlet below.
> >
> > public void doPost(HttpServletRequest request, HttpServletResponse
> > response)
> > throws ServletException, IOException
> > {
> >         response.setContentType("text/html");
> >         PrintWriter out=response.getWriter();
> >         out.println("<html>");
> >                 out.println("<head><title>Invoice
>Entry</title></head>");
> >                 out.println("</body>");
> >         Connection con=null;
> >         Enumeration parameters=request.getParameterNames();
> >         String param = null;
> >         int i=1;
> >
> >         try
> >         {
> >                 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> >                 con = DriverManager.getConnection("jdbc:odbc:veena"," ",
>"
> > ");
> >                 System.out.print("connection");
> >                 Statement st= con.createStatement();
> >                 while (parameters.hasMoreElements())
> >                 {
> >                 param = (String) parameters.nextElement();
> >                 System.out.print("param");
> >                 st.executeUpdate("insert into invoice" + " values (i,
> > request.getParameter(param)");
> >                 i++;
> >                 out.println("<BOLD>" + param + " : " +
> > request.getParameter(param) +
> >                 "</BOLD><BR>");
> >                 }
> >         }
> >
> >         catch(SQLException s)
> >         {
> >         System.err.println(s.getMessage());
> >         }
> >         catch(ClassNotFoundException cn)
> >         {
> >         System.err.println(cn.getMessage());
> >         }
> >         catch(Exception e)
> >         {
> >         System.err.println(e.getMessage());
> >         }
> >
> >         finally
> >         {
> >                 try
> >                 {
> >                 con.close();
> >                 }
> >                 catch(SQLException se)
> >                 {
> >                 System.err.println(se.getMessage());
> >                 }
> >         }
> >
> > out.println("</body></html>");
> > out.close();
> > }
> >
> >
> > veena
> > [EMAIL PROTECTED]
> >
> >
> > ________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> >
> >
>__________________________________________________________________________
> > _
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> > body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to