Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • Java Developer Java Developer
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OnGres Inc.OnGres Inc.
  • InterviewInterview
  • Java DeveloperJava Developer
  • Merge requests
  • !2

Ongres Excercise - Jeevan

  • Review changes

  • Download
  • Patches
  • Plain diff
Open Ghost User requested to merge main into main Feb 22, 2023
  • Overview 0
  • Commits 4
  • Pipelines 0
  • Changes 2

Completed Exercises 1 and 2.

Exercise #1 - Bug hunter

Grouped the films by title to avoid returning duplicate entries. Changed only the inline SQL query on PostgresRepository class. (Method - filmByActorSupplier)

Exercise #2 - Document and refactor

Documented the ResultSetIterator class using Doc comments. I made an improvement to this class and optimized its performance.

In this implementation, the class implements the AutoCloseable interface and adds a close() method that explicitly closes the ResultSet, PreparedStatement, and Connection objects used by the iterator.

class ResultSetIterator<T> implements Iterator<T>, AutoCloseable {

public void close(){
	try {
      resultSet.close();
      statement.close();
      connection.close();
    } catch (SQLException ex) {
      throw new RepositoryException(ex);
    }
}

The hasNext() method calls the close() method when there are no more results in the ResultSet object.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: main