import org.apache.commons.dbutils.DbUtils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCResponder {

    public static void main(String[] args) {

        String query = null;
        String dbConnStr = null;
        String dbUname = null;
        String dbPassw = null;

        try {

            Class.forName("oracle.jdbc.driver.OracleDriver");

        } catch(ClassNotFoundException e) {

            System.out.println("JDBCResponder: Oracle JDBC Driver not found.");
            e.printStackTrace();
            System.exit(0);

        }

        //  System.out.println("JDBCResponder: Oracle JDBC Driver registered.");

        try {

            dbConnStr = args[0];
            dbUname = args[1];
            dbPassw = args[2];
            query = args[3];

        } catch(Exception e) {

            System.out.println(e);
            System.exit(0);

        }

        String rsString = null;
        ResultSet rs = null;
        Statement stmt = null;
        Connection conn = null;

        try {

            conn = DriverManager.getConnection(dbConnStr, dbUname, dbPassw);
            // System.out.println("JDBCResponder: Connected to database.");

            try {

                stmt = conn.createStatement();

                rs = stmt.executeQuery(query);
                ResultSetMetaData rsmd = rs.getMetaData();
                int numberOfColumns = rsmd.getColumnCount();

                while(rs.next()) {



                }

                System.out.println(rsString);

            } catch(SQLException e) {

                System.out.println("JDBCResponder: SQL error.");
                System.out.println(e);

            }

        } catch(Exception e) {

            System.out.println("JDBCResponder: Error.");
            System.out.println(e);

        } finally {

            DbUtils.closeQuietly(rs);
            DbUtils.closeQuietly(stmt);
            DbUtils.closeQuietly(conn);

        }
    }
}

@@ -214,16 +214,39 @@
 atement;
+%0Aimport java.sql.Types;
 %0A%0Apublic
@@ -1401,25 +1401,24 @@
 tatement();%0A
-%0A
             
@@ -1571,16 +1571,50 @@
 Count();
+%0A                int rowCount = 1;
 %0A%0A      
@@ -1643,17 +1643,908 @@
 t()) %7B%0A%0A
-%0A
+                    System.out.println(%22Row %22 + rowCount++ + %22:  %22);%0A%0A                    for (int i = 1; i %3C= numberOfColumns; i++) %7B%0A%0A%0A                        String colName = rsmd.getColumnName(i);%0A                        System.out.print(%22%5Ct%22 + colName + %22:%5Ct%22);%0A%0A                        int type = rs.getType();%0A                        if(type == Types.VARCHAR %7C%7C type == Types.CHAR) %7B%0A%0A                            System.out.println(rs.getNString(i));%0A%0A                        %7D else if(type == Types.DATE) %7B%0A%0A                            System.out.println(rs.getDate(i));%0A%0A                        %7D else if(type == Types.REAL) %7B%0A%0A                            System.out.println(rs.getDouble(i));%0A%0A                        %7D else %7B%0A%0A                            System.out.println(rs.getInt(i));%0A%0A                        %7D%0A                    %7D%0A%0A                    System.out.println(%22%22);
 %0A       

check column type before printing