-
-
Save sasajib/d1cfa00a23656c3f84e8 to your computer and use it in GitHub Desktop.
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
// Imports required | |
import java.sql.ResultSet; | |
import java.sql.ResultSetMetaData; | |
import java.sql.SQLException; | |
/** | |
* Print a result set to system out. | |
* | |
* @param rs The ResultSet to print | |
* @throws SQLException If there is a problem reading the ResultSet | |
*/ | |
final public static void printResultSet(ResultSet rs) throws SQLException | |
{ | |
ResultSetMetaData rsmd = rs.getMetaData(); | |
int columnsNumber = rsmd.getColumnCount(); | |
while (rs.next()) { | |
for (int i = 1; i <= columnsNumber; i++) { | |
if (i > 1) System.out.print(" | "); | |
System.out.print(rs.getString(i)); | |
} | |
System.out.println(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment