java dynamic SQL formatter

import java.sql.*;
 
public class dynColumns {
  public static void main(String[] args) {
    try {
      Connection con = DriverManager.getConnection("jdbc:oracle:thin:" + args[0]);
      Statement stm = con.createStatement();
      ResultSet rst = stm.executeQuery(args[1]);
      ResultSetMetaData rstMeta = rst.getMetaData();
      int columns = rstMeta.getColumnCount();
      while (rst.next()) {
        for (int j = 1; j <= columns; j++) {
          System.out.println(String.format("%1$-30s", rstMeta.getColumnName(j)) + " " + nullToBlank(rst.getString(j)));
        }
        System.out.println(String.format("%1$-30s","").replace(' ', '-'));
      }
      System.out.println(rst.getRow() + " rows found.");
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
  static String nullToBlank(String s) {
    if (s == null) {
      return "";
    }
    else {
      return s;
    }
  }
}