Q: Update statement is not committing to database I'm trying to update a table using Java and MySQL, but I'm hitting a blank with this one.
The Java runs the update query okay but doesn't commit to the database.
Here is the method I'm calling:
    public int qryUpdateRegistry(int registryId, Registry registry) throws SQLException {

    PreparedStatement qry = null;
    Connection conn = null;
    Boolean okayToUpdate = false;

    try {
        conn = connectToDatabase();

        if (registry.getHostId() != 0 && registry.getRegistryName() != null && registry.getEventDate() != null) {
            okayToUpdate = true;
        }



        if (okayToUpdate) {
            String strSql = "UPDATE registry SET host_id = ?, registry_name = ?, registry_guest_pw = ?, registry_event_date = ?, registry_auto_delete_yn = ?, registry_num_days_delete = ? WHERE registry_id = ?";
            qry = conn.prepareStatement(strSql);

            qry.setInt(1, registry.getHostId());
            qry.setString(2, registry.getRegistryName());
            qry.setString(3, registry.getRegistryPassword());
            qry.setDate(4, registry.getEventDate());
            qry.setInt(5, registry.getRegistryAutoDelete());
            qry.setInt(6, registry.getNumDaysDelete());
            qry.setInt(7, registryId);


            qry.executeUpdate();

        }
    } catch (Exception e) {
        e.printStackTrace();
        return 500;
    } finally {
        if (qry != null) {
            qry.close();
        }
        if (conn != null) {
            conn.close();
        }
    }
    return 200; // Server response that it was updated
}

But on the database nothing has changed. I get no SQL exceptions, no errors of any kind.
What's weird is that this update query, done in exactly the same way, works absolutely fine from the Java end.
    public int qryUpdateHostPassword(int hostId, String password)
        throws Exception {
    PreparedStatement qry = null;
    Connection conn = null;
    Boolean okayToInsert = false;

    try {
        conn = connectToDatabase();

        if (hostId != 0 && password != null) {
            okayToInsert = true;
        }

        if (okayToInsert) {
            qry = conn
                    .prepareStatement("UPDATE host SET password = ? WHERE host_id = ?");

            qry.setString(1, password);
            qry.setInt(2, hostId);

            qry.executeUpdate();
        }
    } catch (Exception e) {
        e.printStackTrace();
        return 500; // Server error
    } finally {
        if (qry != null) {
            qry.close();
        }
        if (conn != null) {
            conn.close();
        }
    }

    return 200; // Server response that it was inserted
}

Any ideas as to what could be causing the database to not update?

A: The only thing that i can think of is that you have autoCommit false.
What does the connectToDatabase()?
Anyway you can do this:
conn = connectToDatabase();
conn.setAutoCommit(true);

Or just verify that you don't put false when you are creating connection with autoCommit false

A: The problem lay with my path parameters called in a different class.
It ran okay, but was always trying to update a record with a registry_id of 0;
    @Path("/reg/{registryID}")

Should have been:
    @Path("/reg/{registryId}")

So of course, when I used:
    @PathParam("registryId") int registryId

So int registryId would always be 0;
I only noticed it when I checked to see what ID it was trying to use.
