コード例 #1
0
ファイル: MysqlDataAct.java プロジェクト: muyutingfeng/jeecms
 private String createOneInsertSql(Object[] oneResult, String tablename) {
   StringBuffer buffer = new StringBuffer();
   buffer.append(
       Constants.ONESQL_PREFIX
           + INSERT_INTO
           + SPLIT
           + tablename
           + SPLIT
           + SPACE
           + VALUES
           + LEFTBRACE);
   for (int j = 0; j < oneResult.length; j++) {
     if (oneResult[j] != null) {
       if (oneResult[j] instanceof Date) {
         buffer.append(QUOTES + oneResult[j] + QUOTES);
       } else if (oneResult[j] instanceof String) {
         buffer.append(QUOTES + StrUtils.replaceKeyString((String) oneResult[j]) + QUOTES);
       } else if (oneResult[j] instanceof Boolean) {
         if ((Boolean) oneResult[j]) {
           buffer.append(1);
         } else {
           buffer.append(0);
         }
       } else {
         buffer.append(oneResult[j]);
       }
     } else {
       buffer.append(oneResult[j]);
     }
     buffer.append(COMMA);
   }
   buffer = buffer.deleteCharAt(buffer.lastIndexOf(COMMA));
   buffer.append(RIGHTBRACE + BRANCH + BR);
   return buffer.toString();
 }
コード例 #2
0
 @Transactional(readOnly = true)
 public String createTableDataSQL(String tablename) {
   StringBuffer buffer = new StringBuffer();
   List<Object[]> results = dao.createTableData(tablename);
   for (Object[] oneResult : results) {
     buffer.append(Constants.ONESQL_PREFIX + INSERT_INTO + tablename + VALUES + LEFTBRACE);
     for (int j = 0; j < oneResult.length; j++) {
       if (oneResult[j] != null) {
         if (oneResult[j] instanceof Date) {
           buffer.append(QUOTES + oneResult[j] + QUOTES);
         } else if (oneResult[j] instanceof String) {
           buffer.append(QUOTES + StrUtils.replaceKeyString((String) oneResult[j]) + QUOTES);
         } else if (oneResult[j] instanceof Boolean) {
           if ((Boolean) oneResult[j]) {
             buffer.append(1);
           } else {
             buffer.append(0);
           }
         } else {
           buffer.append(oneResult[j]);
         }
       } else {
         buffer.append(oneResult[j]);
       }
       buffer.append(COMMA);
     }
     buffer = buffer.deleteCharAt(buffer.lastIndexOf(COMMA));
     buffer.append(RIGHTBRACE + BRANCH + BR);
   }
   return buffer.toString();
 }