I use `ajax` to submit data to a `servlet`. The ajax call appears to be successful. I believe I'm catching the posted data correctly and using `jdbc` to submit the data to `mysql` but the record doesn't get added and there are no exception error messages in the console.

Heres the servlet code:

```
@WebServlet(description = "submits comment to mysql database", urlPatterns = { "/CommentController" })
public class CommentController extends HttpServlet {
    private static final long serialVersionUID = 1L;

    private static Connection conn; 
    private PreparedStatement prep;
    private String sql;
    private ResultSet rs;
    private static final String driver = "com.mysql.jdbc.Driver", host = "jdbc:mysql://host/", dbName = "name", username = "user", password = "pw";

    /**
     * @see HttpServlet#HttpServlet()
     */
    public CommentController() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        String commentName = request.getParameter("name");
        String comment = request.getParameter("comment");
        int postID = Integer.parseInt(request.getParameter("postID"));

        try{
            Class.forName(driver);
            Connection conn = (Connection) DriverManager.getConnection(host + dbName, username, password);
            sql="INSERT INTO crm_comments (comment_name, comment_content, comment_date, post_id) VALUES (?, ?, NOW(), ?)";
            prep = conn.prepareStatement(sql);
            prep.setString(1, commentName);
            prep.setString(2, comment);
            prep.setInt(3, postID);
            rs = prep.executeQuery();

        }catch(Exception e){
            e.printStackTrace();
        }
        System.out.println("yes");
    }
}

```

The html form:

```
<form id="commentForm" name="commentForm" action="http://localhost:8080/chrismepham/CommentController" method="POST">
    <input type="text" name="name" placeholder="Your name" required="required">
    <textarea name="comment" placeholder="Enter your comment here (max. 500 characters)" required="required"></textarea>
    <input type="hidden" name="catcher" id="catcher">
    <input type="hidden" name="postID" id="postID" value="<%= postID %>">
    <input type="submit" name="submit" id="commentSubmit" value="submit">
</form>

```

ajax:

```
$("#commentSubmit").click(function(e){
    var postData = $("#commentForm").serializeArray();
    var formURL = $("#commentForm").attr("action");
    //var catcher = $("#catcher").val();
        $.ajax(
        {

            type: "POST",
            url : formURL,
            data : postData,
            success:function(data, textStatus, jqXHR) 
            {
                $("#commentFormWrap").html("<p>Success</p>");
            },
            error: function(jqXHR, textStatus, errorThrown) 
            {
                $("#commentFormWrap").html("<p>ss"+errorThrown+textStatus+jqXHR+"</p>");
            }
        });
    e.preventDefault(); //STOP default action
    $("#commentForm").hide();
});

```

Could some one tell me what might be wrong here that is preventing the data being recorded in `MySQL`?