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

Connected

Exercise

Working with Statements

CityBook Libraries wants to query their books table. To execute SQL queries in JDBC, you need to create a Statement object from your connection, then use it to run queries and get results.

The database credentials are preloaded in the Credentials class, and all necessary imports (Connection, DriverManager, SQLException, Statement, ResultSet) are available.

Instructions

100 XP
  • Create a Statement from the connection.
  • Execute the query using the Statement to get a ResultSet.