try {
    Class.forName(driver);
    con = DriverManager.getConnection(url + db, user, pass);
    PreparedStatement st = con.prepareStatement(
        "INSERT INTO menu(menu.menuID,menu.name,menu.info,menu.price) values(?,?,?,?)");
    st.setString(1, value1);
    st.setString(2, value2);
    st.setString(3, value3);
    st.setString(4, value4);
    st.executeUpdate();
    JOptionPane.showMessageDialog(p1, "Data is successfully inserted into database.");
    con.close();
} catch (Exception e) {
    JOptionPane.showMessageDialog(p1,
            "Error in submitting data!");
}
I ran FindBugs and this is the bug that is coming on line 3:
Hardcoded constant database password in
ie.lyit.flight.Changeadd$3.actionPerformed(ActionEvent)This code creates a database connect using a hardcoded, constant password. Anyone with access to either the source code or the compiled code can easily learn the password.
Rank: Scary (7), confidence: Normal Pattern: DMI_CONSTANT_DB_PASSWORD Type: Dm, Category: SECURITY (Security)
I was wondering if anyone knows how to get rid of this bug and how I would go about doing it?
 
     
     
     
     
    