Java Utililty Methods SQL ResultSet

List of utility methods to do SQL ResultSet

Description

The list of methods to do SQL ResultSet are organized into topic(s).

Method

voidsaveResultsetAsFile(ResultSet rs, String filePath, String fileName)
save Resultset As File
logger.info("Inside cacheResultSet function");
logger.info("The name of the file passed here is" + fileName);
FileWriter out = null;
try {
    out = new FileWriter(filePath + fileName);
    ResultSetMetaData metaData = rs.getMetaData();
    int numberOfColumns = metaData.getColumnCount();
    while (rs.next()) {
...
StringtoXML(ResultSet rs)
Create xml string - fastest, but may have encoding issues
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount();
StringBuilder xml = new StringBuilder();
xml.append("<Results>");
while (rs.next()) {
    xml.append("<Row>");
    for (int i = 1; i <= colCount; i++) {
        String columnName = rsmd.getColumnName(i);
...
voidwriteResultSetToFile(String path, ResultSet results)
write Result Set To File
ResultSetMetaData metaData = results.getMetaData();
int columnCount = metaData.getColumnCount();
try {
    BufferedWriter bw = Files.newBufferedWriter(Paths.get(path), StandardOpenOption.CREATE);
    bw.write("**************** SQL DEBUG ****************\n");
    bw.write("*******************************************\n");
    bw.write("*******************************************\n");
    while (results.next()) {
...