Look in either the err or event log for the JRun server to see if it displays an 
error.  This should give you an idea of where the problem is.

Ted Zimmerman

-----Original Message-----
From: Boogie Brown [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 4:58 PM
To: JRun-Talk
Subject: Servlets and DB - Same Fustrated Newbie, Please Help


I am having issues inserting data into a Database using a servlet.
My code is:

                // receiving parameters

                String strUserID = req.getParameter("txtUserID").trim();
                String strUserTypeID = req.getParameter("txtUserTypeID").trim();
                //int txtUserId = Integer(strUserID);
                //int txtUserTypeID = Integer(strUserTypeID);
                String comments = req.getParameter("notes").trim();
                boolean proceed = false;

                if(strUserID != null && strUserTypeID != null && comments != null)
                        if(comments.length() > 0)
                                proceed = true;

                // connecting to database
                Connection con = null;
                Statement stmt = null;
                PreparedStatement ps = null;

                try {
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        con=DriverManager.getConnection(dBURL);
                        //making the connection

                        String sql = "Insert Into tblUserNotepad(userID, userTypeID, 
comments) 
(?,?,?)";
                        ps = con.prepareStatement(sql);
                        stmt = con.createStatement();

                        if(proceed) {
                                ps.setString(1, strUserID);
                                ps.setString(2, strUserTypeID);
                                ps.setString(3, comments);
                                ps.executeUpdate();
                        }
                        out.print("<h1>Error 1 </h1>");


                } catch (SQLException e) {
                        out.print("<h1>Error 2 </h1>");
                        throw new ServletException(e);
                } catch (ClassNotFoundException e) {
                        out.print("<h1>Error 3 </h1>");
                        throw new ServletException(e);
                } finally {
                        try {
                                if(stmt != null)
                                        stmt.close();
                                if(ps != null)
                                        ps.close();
                                if(con != null)
                                        con.close();
                        } catch (SQLException e) {}
                }

                out.print("</body></html>");
                out.close();
        }


I get returned a "The page cannot be displayed" error.
1) How can I debug this?
2) How can I make this work?

Thanks one more time.
MTB



______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to