I have the following code snippet where I check a soap results and insert data into my database.
Connection dbconn = null;
    Statement stmt1 = null;
    Statement stmt2 = null;
    try
    {
        dbconn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test1", "tes1", "te15");
        stmt1 = dbconn.createStatement();
        stmt2 = dbconn.createStatement();
        DateFormat outDf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = Calendar.getInstance().getTime();
        String value = null;
        for (int i = 0; i < list.getLength(); i++)
        {
           Element eElement = (Element) e.getChildNodes();
            String Contents = eElement.getElementsByTagName("Content").item(0).getTextContent();  
            String insertCommand = "INSERT INTO command SET content='"+content+"'";
            System.out.println("\n SET INSERT :" + insertCommand);
            int count = stmt1.executeUpdate(insertCommand);
        }
    }
What I notice is like this as the content DCN5�716732412? So when I used this content for the next process I get a bad request error. How can I sanitize if the content had funny character to avoid in the first place itself? 
 
     
    