title: Why is my row not updating?
body: <p>I've created a Prepared Statement that should be updating a row, however, the row does not update.</p>
  
  <pre><code>    /**
   * Sets the last modified date of the Index to Now();
   * Automatically gets the number of files and total size of files in index that are included in the index and sets that data too.
   * @return
   * @throws SQLException 
   * @throws ClassNotFoundException 
   * @throws UnexpectedException 
   */
  public void MarkUpdated() throws ClassNotFoundException, SQLException, UnexpectedException
  {
      Connection connection = null;
      PreparedStatement statement1 = null;
      PreparedStatement statement2 = null;
      PreparedStatement statement3 = null;
      ResultSet rSet1 = null;
      ResultSet rSet2 = null;
      // First, lets obtain the file count
      try
      {
      Integer count;
      connection = ConnectionMgr.getConnectionToSc1();
      connection.setAutoCommit(true);
      statement1 = connection.prepareStatement
              ("SELECT COUNT(*) FROM indexFiles WHERE IndexID=? AND IndexUUID=?");
      statement1.setLong(1, IndexID);
      statement1.setString(2, IndexUUID);
      rSet1 = statement1.executeQuery();
      if (rSet1.next())
      {
  
          count = rSet1.getInt(1);
  
      }
      else
      {
          throw new UnexpectedException("Failed to Mark Updated - Couldn't get file count?");
      }
      // Now lets obtain the total amount of disk space these files are occupying
      // This is a bit more complicated
      Long size;
      statement2 = connection.prepareStatement
              ("SELECT SUM(FileSize) FROM files WHERE FileUUID IN "
              +"(SELECT FileUUID FROM indexFiles WHERE IndexID=? AND IndexUUID=?)");
      statement2.setLong(1, IndexID);
      statement2.setString(2, IndexUUID);
      rSet2 = statement2.executeQuery();
      if (rSet2.next())
      {
          size = rSet2.getLong(1);
      }
      else
      {
          throw new UnexpectedException("Failed to Mark Updated - Couldn't get sum of file sizes?");
      }
  
  
  
  
      // Now we mark the index as updated with the new file count
      statement3 = connection.prepareStatement
              ("UPDATE indexes SET FileCount=? AND Size=? WHERE IndexID=? AND IndexUUID=?");
      statement3.setInt(1, count);
      statement3.setLong(2, size);
      statement3.setLong(3, IndexID);
      statement3.setString(4, IndexUUID);
      //if (1 != 0)
      //{
      //  throw new UnexpectedException("Count " + count + " Size " + size + " IndexID " + IndexID + " IndexUUID " + IndexUUID);
      //}
      int rowsUpdated = statement3.executeUpdate();
      if (rowsUpdated != 1) {throw new UnexpectedException("Failed to mark an index as updated: Index UUID is " + IndexUUID);}
      } finally {
          DbUtils.closeQuietly(rSet1);
          DbUtils.closeQuietly(rSet2);
          DbUtils.closeQuietly(statement1);
          DbUtils.closeQuietly(statement2);
          DbUtils.closeQuietly(statement3);
          DbUtils.closeQuietly(connection);
      }
  }
  </code></pre>
  
  <p>Purposely thrown exception
  <a href="https://i.stack.imgur.com/Y4m14.png" rel="nofollow noreferrer">Purposely thrown exception</a></p>
  
  <p>You can see from my debug code I tried throwing an exception to see that everything is set correctly. I can confirm that a row with this IndexID/UUID exists in my table.</p>
  
  <p>The statement is executed and no exception is thrown indicating that an update occured - however, when checking my table, these values are not updated.</p>
  
  <p>I'm trying to figure out why that might be? I have checked and I have not set autocommit to false when constructing my connection. The columns FileCount and Size are both set to default '0' - but default values should not override statement values, right?</p>
  
  <p>Thanks in advance for help</p>