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

Reply via email to