public static void main(String[] args) { boolean successFlag = false; CreateConnection.loadProperties(); try (Connection conn = CreateConnection.getConnection(); ) { // Perform Scrollable Query queryBookAuthor(conn); queryAuthorWork(conn); joinRowQuery(); } catch (java.sql.SQLException ex) { System.out.println(ex); } finally { if (bookAuthors != null) { try { bookAuthors.close(); } catch (SQLException ex) { ex.printStackTrace(); } } if (authorWork != null) { try { authorWork.close(); } catch (SQLException ex) { ex.printStackTrace(); } } if (jrs != null) { try { jrs.close(); } catch (SQLException ex) { ex.printStackTrace(); } } } }
public static void joinRowQuery() { try { // Create JoinRowSet jrs = new JoinRowSetImpl(); // Add RowSet & Corresponding Keys jrs.addRowSet(bookAuthors, 1); jrs.addRowSet(authorWork, 2); // Traverse Results while (jrs.next()) { System.out.println( jrs.getString("BOOK_ID") + " - " + jrs.getString("FIRSTNAME") + " " + jrs.getString("LASTNAME")); } } catch (SQLException ex) { ex.printStackTrace(); } }