Q:

Values not being added to database when adding a conditional if statement that should apply

I'm having a bit of problem when trying to add things to my database.
If I don't use an if statement such as this, it works:
public void onMessage(String channel, String sender, String login, String hostname, String message) {

    String[] splitMessage = message.split(" ", 3);

        try {

            conn = TwitchBotMain.getConnection();
            String query = "insert ignore into commands(name, output) values(?,?)";

            pstmt = conn.prepareStatement(query);
            pstmt.setString(1,  splitMessage[1]);
            pstmt.setString(2,  splitMessage[2]);
            pstmt.executeUpdate();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                pstmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
    }

However, if I add this if statement to the mix, it doesn't log anything to the database:
public void onMessage(String channel, String sender, String login, String hostname, String message) {

    String[] splitMessage = message.split(" ", 3);

    if (splitMessage[0] == "!add") {

        try {

            conn = TwitchBotMain.getConnection();
            String query = "insert ignore into commands(name, output) values(?,?)";

            pstmt = conn.prepareStatement(query);
            pstmt.setString(1,  splitMessage[1]);
            pstmt.setString(2,  splitMessage[2]);
            pstmt.executeUpdate();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                pstmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}

Eclipse isn't showing any Java errors.

A:

Always use equals() instead of == when compare string:
if (splitMessage[0].equals("!add"))

