Skip to content

Commit a611a28

Browse files
committed
Server:解决在数据库返回结果中所有column的值都为空时导致查询数据不全
1 parent 2b20ee1 commit a611a28

File tree

1 file changed

+20
-17
lines changed
  • APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/zuo/biao/apijson/server/sql

1 file changed

+20
-17
lines changed

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class SQLExecutor {
6767
private synchronized Connection getConnection() throws Exception {
6868
Log.i(TAG, "成功加载MySQL驱动!");
6969
return DriverManager.getConnection(SQLConfig.MYSQL_URI + "?useUnicode=true&characterEncoding=UTF-8&user="
70-
+ SQLConfig.MYSQL_ACCOUNT + "&password=" + SQLConfig.MYSQL_PASSWORD);
70+
+ SQLConfig.MYSQL_ACCOUNT + "&password=" + SQLConfig.MYSQL_PASSWORD);
7171
}
7272

7373
/**保存缓存
@@ -251,26 +251,29 @@ public JSONObject execute(SQLConfig config) throws Exception {
251251
+ " >> } catch (Exception e) {");
252252
e.printStackTrace();
253253
}
254-
if (value == null) {
255-
Log.i(TAG, "select while (rs.next()){ ..." + " >> value == null >> continue;");
256-
continue;
257-
}
254+
// if (value == null) {
255+
// Log.i(TAG, "select while (rs.next()){ ..." + " >> value == null >> continue;");
256+
// continue;
257+
// }
258258

259259
// Log.i(TAG, "select while (rs.next()) { >> for (int i = 0; i < columnArray.length; i++) {"
260260
// + "\n >>> columnArray[i]) = " + columnArray[i] + "; value = " + value);
261-
if (value instanceof Timestamp) {
262-
value = ((Timestamp) value).toString();
263-
}
264-
else if (value instanceof String) {
265-
try {
266-
json = JSON.parse((String) value);
267-
if (json != null && json instanceof JSON && StringUtil.isNotEmpty(json, true)) {
268-
value = json;
261+
262+
if (value != null) { //数据库查出来的null和empty值都有意义,去掉会导致 Moment:{ @column:"content" } 部分无结果及中断数组查询!
263+
if (value instanceof Timestamp) {
264+
value = ((Timestamp) value).toString();
265+
}
266+
else if (value instanceof String) {
267+
try {
268+
json = JSON.parse((String) value);
269+
if (json != null && json instanceof JSON && StringUtil.isNotEmpty(json, true)) {
270+
value = json;
271+
}
272+
} catch (Exception e) {
273+
//太长 Log.i(TAG, "select while (rs.next()){ >> i = "
274+
// + i + " try { json = JSON.parse((String) value);"
275+
// + ">> } catch (Exception e) {\n" + e.getMessage());
269276
}
270-
} catch (Exception e) {
271-
//太长 Log.i(TAG, "select while (rs.next()){ >> i = "
272-
// + i + " try { json = JSON.parse((String) value);"
273-
// + ">> } catch (Exception e) {\n" + e.getMessage());
274277
}
275278
}
276279

0 commit comments

Comments
 (0)