@@ -199,37 +199,14 @@ public JSONObject execute(SQLConfig config) throws Exception {
199199 Log .d (TAG , "\n \n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n select while (rs.next()){ index = " + index + "\n \n " );
200200
201201 result = new JSONObject (true );
202- Object value ;
203202
204203 for (int i = 1 ; i <= length ; i ++) {
205- if (rsmd .getColumnName (i ).startsWith ("_" )) {
206- Log .i (TAG , "select while (rs.next()){ ..."
207- + " >> rsmd.getColumnName(i).startsWith(_) >> continue;" );
208- continue ;
209- }
210-
211- value = rs .getObject (i );
212- // Log.d(TAG, "name:" + rsmd.getColumnName(i));
213- // Log.d(TAG, "lable:" + rsmd.getColumnLabel(i));
214- // Log.d(TAG, "type:" + rsmd.getColumnType(i));
215- // Log.d(TAG, "typeName:" + rsmd.getColumnTypeName(i));
216-
217- // Log.i(TAG, "select while (rs.next()) { >> for (int i = 0; i < length; i++) {"
218- // + "\n >>> value = " + value);
219-
220- if (value != null ) { //数据库查出来的null和empty值都有意义,去掉会导致 Moment:{ @column:"content" } 部分无结果及中断数组查询!
221- if (value instanceof Timestamp ) {
222- value = ((Timestamp ) value ).toString ();
223- }
224- else if (value instanceof String && isJSONType (rsmd , i )) { //json String
225- value = JSON .parse ((String ) value );
226- }
227- }
228-
229- result .put (rsmd .getColumnLabel (i ), value );
204+
205+ result = onPutColumn (config , rs , rsmd , index , result , i );
230206 }
231207
232- resultMap .put (index , result );
208+ resultMap = onPutTable (config , rs , rsmd , resultMap , index , result );
209+
233210 Log .d (TAG , "\n select while (rs.next()) { resultMap.put( " + index + ", result); "
234211 + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>> \n \n " );
235212 }
@@ -246,6 +223,66 @@ else if (value instanceof String && isJSONType(rsmd, i)) { //json String
246223 }
247224
248225
226+ /**table.put(rsmd.getColumnLabel(i), rs.getObject(i));
227+ * @param config
228+ * @param rs
229+ * @param rsmd
230+ * @param tablePosition 从0开始
231+ * @param table
232+ * @param columnIndex 从1开始
233+ * @return result
234+ * @throws Exception
235+ */
236+ protected JSONObject onPutColumn (@ NotNull SQLConfig config , @ NotNull ResultSet rs , @ NotNull ResultSetMetaData rsmd
237+ , int tablePosition , @ NotNull JSONObject table , int columnIndex ) throws Exception {
238+
239+ if (rsmd .getColumnName (columnIndex ).startsWith ("_" )) {
240+ Log .i (TAG , "select while (rs.next()){ ..."
241+ + " >> rsmd.getColumnName(i).startsWith(_) >> continue;" );
242+ return table ;
243+ }
244+
245+ Object value = rs .getObject (columnIndex );
246+ // Log.d(TAG, "name:" + rsmd.getColumnName(i));
247+ // Log.d(TAG, "lable:" + rsmd.getColumnLabel(i));
248+ // Log.d(TAG, "type:" + rsmd.getColumnType(i));
249+ // Log.d(TAG, "typeName:" + rsmd.getColumnTypeName(i));
250+
251+ // Log.i(TAG, "select while (rs.next()) { >> for (int i = 0; i < length; i++) {"
252+ // + "\n >>> value = " + value);
253+
254+ if (value != null ) { //数据库查出来的null和empty值都有意义,去掉会导致 Moment:{ @column:"content" } 部分无结果及中断数组查询!
255+ if (value instanceof Timestamp ) {
256+ value = ((Timestamp ) value ).toString ();
257+ }
258+ else if (value instanceof String && isJSONType (rsmd , columnIndex )) { //json String
259+ value = JSON .parse ((String ) value );
260+ }
261+ }
262+
263+ table .put (rsmd .getColumnLabel (columnIndex ), value );
264+
265+ return table ;
266+ }
267+
268+ /**resultMap.put(position, table);
269+ * @param config
270+ * @param rs
271+ * @param rsmd
272+ * @param resultMap
273+ * @param position
274+ * @param table
275+ * @return resultMap
276+ */
277+ protected Map <Integer , JSONObject > onPutTable (@ NotNull SQLConfig config , @ NotNull ResultSet rs , @ NotNull ResultSetMetaData rsmd
278+ , @ NotNull Map <Integer , JSONObject > resultMap , int position , @ NotNull JSONObject table ) {
279+
280+ resultMap .put (position , table );
281+ return resultMap ;
282+ }
283+
284+
285+
249286 /**判断是否为JSON类型
250287 * @param rsmd
251288 * @param position
0 commit comments