I have several methods that do the same thing yet, when interfacing with the MySQL database, save or load a different type of parameter. Currently, I have a different method
What if you broke out your comparative functionality and had your methods down to the most granular level? For example:
public static void update(Connection con, int playerID, String tableName, String fieldName, String value) {
// update query logic here
}
And the same for delete()
. There is no reason to pass both the "new" and "original" values into this function and do the compare inside. I suggest looping through the arrays, comparing, and calling either update()
or delete()
based on your needs. To deal with different data types, I would always pass in the String
value of what you want in the database.