Program: 76693
Project: 76693
Buggy source:
/** 
 * Creates a new tag in the database.
 * @param provider The connection to the database.
 * @param parent The parent tag of the tag.
 * @param name The name of the new tag.
 * @param description The description of the new tag.
 * @param type The type of the new tag.
 * @return The new tag.
 * @throws CouldntSaveDataException Thrown if creating the tag failed.
 */
public static CTag createTag(final AbstractSQLProvider provider,final CTag parent,final String name,final String description,final TagType type) throws CouldntSaveDataException {
  checkArguments(provider,parent,type);
  Preconditions.checkNotNull(name,"String_Node_Str");
  Preconditions.checkNotNull(description,"String_Node_Str");
  final CConnection connection=provider.getConnection();
  final String query="String_Node_Str" + CTableNames.TAGS_TABLE + "String_Node_Str";
  try (PreparedStatement statement=connection.getConnection().prepareStatement(query,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);ResultSet resultSet=statement.executeQuery()){
    if (parent.getId() == 0) {
      statement.setNull(1,Types.INTEGER);
    }
 else {
      statement.setInt(1,parent.getId());
    }
    statement.setString(2,name);
    statement.setString(3,description);
    statement.setString(4,tagToString(type));
    Integer id=null;
    while (resultSet.next()) {
      if (resultSet.isFirst()) {
        id=resultSet.getInt(1);
      }
    }
    if (id != null) {
      return new CTag(id,name,description,type,provider);
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
 catch (  final SQLException e) {
    throw new CouldntSaveDataException(e);
  }
}

Fixed version (ground truth):
/** 
 * Creates a new tag in the database.
 * @param provider The connection to the database.
 * @param parent The parent tag of the tag.
 * @param name The name of the new tag.
 * @param description The description of the new tag.
 * @param type The type of the new tag.
 * @return The new tag.
 * @throws CouldntSaveDataException Thrown if creating the tag failed.
 */
public static CTag createTag(final AbstractSQLProvider provider,final CTag parent,final String name,final String description,final TagType type) throws CouldntSaveDataException {
  checkArguments(provider,parent,type);
  Preconditions.checkNotNull(name,"String_Node_Str");
  Preconditions.checkNotNull(description,"String_Node_Str");
  final CConnection connection=provider.getConnection();
  final String query="String_Node_Str" + CTableNames.TAGS_TABLE + "String_Node_Str";
  try (PreparedStatement statement=connection.getConnection().prepareStatement(query,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY)){
    if (parent.getId() == 0) {
      statement.setNull(1,Types.INTEGER);
    }
 else {
      statement.setInt(1,parent.getId());
    }
    statement.setString(2,name);
    statement.setString(3,description);
    statement.setString(4,tagToString(type));
    Integer id=null;
    try (ResultSet resultSet=statement.executeQuery()){
      while (resultSet.next()) {
        if (resultSet.isFirst()) {
          id=resultSet.getInt(1);
        }
      }
    }
     if (id != null) {
      return new CTag(id,name,description,type,provider);
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
 catch (  final SQLException e) {
    throw new CouldntSaveDataException(e);
  }
}