1. Learn
  2. /
  3. Courses
  4. /
  5. Querying a PostgreSQL Database in Java

Connected

Exercise

Reading sample chapters

The Metropolitan Public Library's "Try Before You Borrow" feature is successfully storing sample chapters. Now you need to implement the retrieval functionality so patrons can actually read these previews on the library's website.

Since sample chapters can contain thousands of characters, you'll use streaming to read the data efficiently. Instead of loading entire chapters into memory at once, you'll read them in small chunks using a character buffer.

Instructions

100 XP
  • Read the stream from the result set for the sample_chapter column.
  • Set the buffer size to read 30 characters.