Created
February 4, 2019 08:53
-
-
Save rnestertsov/70746d12f09739a06d26ebc747a933b0 to your computer and use it in GitHub Desktop.
Print JDBC result set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void printResults(ResultSet rs) throws SQLException { | |
| ResultSetMetaData rsMetadata = rs.getMetaData(); | |
| for (int i=1; i<=rsMetadata.getColumnCount(); i++) { | |
| System.out.printf("%-15s | ", rsMetadata.getColumnName(i)); | |
| } | |
| System.out.printf("\n"); | |
| while (rs.next()) { | |
| for (int i=1; i<=rsMetadata.getColumnCount(); i++) { | |
| System.out.printf("%-15s | ", rs.getString(i)); | |
| } | |
| System.out.printf("\n"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment