(int ncol)
| 84 | } // end of main |
| 85 | |
| 86 | private static void PrintResult(int ncol) { |
| 87 | // Get result set meta data |
| 88 | int i; |
| 89 | Date date = new Date(0); |
| 90 | Time time = new Time(0); |
| 91 | Timestamp tsp = new Timestamp(0); |
| 92 | String columnName; |
| 93 | Object job; |
| 94 | |
| 95 | // Get the column names; column indices start from 1 |
| 96 | for (i = 1; i <= ncol; i++) { |
| 97 | columnName = jdi.ColumnName(i); |
| 98 | |
| 99 | if (columnName == null) |
| 100 | return; |
| 101 | |
| 102 | // Get the name of the column's table name |
| 103 | //String tableName = rsmd.getTableName(i); |
| 104 | |
| 105 | if (i > 1) |
| 106 | System.out.print("\t"); |
| 107 | |
| 108 | System.out.print(columnName); |
| 109 | } // endfor i |
| 110 | |
| 111 | System.out.println(); |
| 112 | |
| 113 | // Loop through the result set |
| 114 | while (jdi.ReadNext() > 0) { |
| 115 | for (i = 1; i <= ncol; i++) { |
| 116 | if (i > 1) |
| 117 | System.out.print("\t"); |
| 118 | |
| 119 | if (DEBUG) |
| 120 | System.out.print("(" + jdi.ColumnType(i, null) + ")"); |
| 121 | |
| 122 | switch (jdi.ColumnType(i, null)) { |
| 123 | case java.sql.Types.VARCHAR: |
| 124 | case java.sql.Types.LONGVARCHAR: |
| 125 | case java.sql.Types.CHAR: |
| 126 | case 1111: |
| 127 | System.out.print(jdi.StringField(i, null)); |
| 128 | break; |
| 129 | case java.sql.Types.INTEGER: |
| 130 | System.out.print(jdi.IntField(i, null)); |
| 131 | break; |
| 132 | case java.sql.Types.BIGINT: |
| 133 | System.out.print(jdi.BigintField(i, null)); |
| 134 | break; |
| 135 | case java.sql.Types.TIME: |
| 136 | time.setTime((long)jdi.TimeField(i, null) * 1000); |
| 137 | System.out.print(time); |
| 138 | break; |
| 139 | case java.sql.Types.DATE: |
| 140 | date.setTime((long)jdi.DateField(i, null) * 1000); |
| 141 | System.out.print(date); |
| 142 | break; |
| 143 | case java.sql.Types.TIMESTAMP: |
no test coverage detected