隨筆-71  評論-5  文章-0  trackbacks-0
           
          select SYSDATE(),date_add(create_date, interval 30 minute);



          MySQL 為日期增加一個時間間隔:date_add()

          set @dt = now();
          select date_add(@dt, interval 1 day); -- add 1 day
          select date_add(@dt, interval 1 hour); -- add 1 hour
          select date_add(@dt, interval 1 minute); -- ...
          select date_add(@dt, interval 1 second);
          select date_add(@dt, interval 1 microsecond);
          select date_add(@dt, interval 1 week);
          select date_add(@dt, interval 1 month);
          select date_add(@dt, interval 1 quarter);
          select date_add(@dt, interval 1 year);
          select date_add(@dt, interval -1 day); -- sub 1 day

          select case when date_add(create_date, interval 30 minute)<SYSDATE()  then 1 else 0 end 
          from  table 
          where id=?




          posted @ 2015-01-08 10:08 藤本薔薇 閱讀(202) | 評論 (0)編輯 收藏


          剛剛調試接口,sql 查詢時 遇到一個問題,報錯  “java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

          其原因是數據庫字段存在這樣的值



          百度了下:
          這是因為 “0000-00-00 00:00:00”在mysql中是作為一個特殊值存在的,但是在Java中, java.sql.Date 會被視為 不合法的值,被JVM認為格式不正確。

          解決辦法:

          在jdbc的url加上   zeroDateTimeBehavior參數:

          datasource.url=jdbc:mysql://localhost:3306/pe?useUnicode=true&characterEncoding=gbk &zeroDateTimeBehavior=convertToNull


             完了過后,報異常

          The reference to entity "characterEncoding" must end with the ';' delimiter   

          其原因可能是在Properties文件或者xml文件中忘記進行特殊符號的轉譯了,


                需要把后面的;修噶為&amp;修改為

          useUnicode=true&amp;characterEncoding=UTF-8 &amp;zeroDateTimeBehavior=convertToNull 

          有以下幾類字符要進行轉義替換:

          &lt;

          <

          小于號

          &gt;

          >

          大于號

          &amp;

          &

          &apos;

          '

          單引號

          &quot;

          "

          雙引號



          問題解決





          posted @ 2014-12-30 11:37 藤本薔薇 閱讀(221) | 評論 (0)編輯 收藏

          Parameter index out of range (1 > number of parameters, which is 0)

          剛剛遇到這個錯,百度了下,說

          應該是調用越界問題吧:
          "參數索引越界"(參數不能少于1個)

          一般是 sql語句少了問號
          sql語句有問題


          后來仔細看了下,原來是自己的SQl的where 語句中?我寫成了中文的輸入法中的? 粗心啊
          posted @ 2014-12-26 14:26 藤本薔薇 閱讀(229) | 評論 (0)編輯 收藏
          str.append(" left join (
          select customer_no,(case  when auth_type=1 then count(route) when auth_type=2 then count(route) when auth_type=3 then count(route) end) as auth_image from h_auth_info where audit_sign=1) h6
          ");




          select  auth_info.customer_no,
          (case when auth_info.auth_image=3 then 1 
                when auth_info.auth_image<3 then 0 
          end)
          as auth_result
          from(
          select customer_no,
          (case  when auth_type=1 then count(route) 
                 when auth_type=2 then count(route) 
                 when auth_type=3 then count(route) 
           end) 
          as auth_image 
          from h_auth_info 
          where audit_sign=1  and customer_no='18632116655'
          )  auth_info
          posted @ 2014-12-26 09:14 藤本薔薇 閱讀(195) | 評論 (0)編輯 收藏
            /**
                   * 校驗銀行卡卡號
                   * 
          @param cardId
                   * 
          @return
                   
          */
                  public static boolean checkBankCard(String cardId) {
                           char bit = getBankCardCheckCode(cardId.substring(0, cardId.length() - 1));
                           if(bit == 'N'){
                               return false;
                           }
                           return cardId.charAt(cardId.length() - 1) == bit;
                  }
                 
                  /**
                   * 從不含校驗位的銀行卡卡號采用 Luhm 校驗算法獲得校驗位
                   * 
          @param nonCheckCodeCardId
                   * 
          @return
                   
          */
                  public static char getBankCardCheckCode(String nonCheckCodeCardId){
                      if(nonCheckCodeCardId == null || nonCheckCodeCardId.trim().length() == 0
                              || !nonCheckCodeCardId.matches("\\d+")) {
                          //如果傳的不是數據返回N
                          return 'N';
                      }
                      char[] chs = nonCheckCodeCardId.trim().toCharArray();
                      int luhmSum = 0;
                      for(int i = chs.length - 1, j = 0; i >= 0; i--, j++) {
                          int k = chs[i] - '0';
                          if(j % 2 == 0) {
                              k *= 2;
                              k = k / 10 + k % 10;
                          }
                          luhmSum += k;           
                      }
                      return (luhmSum % 10 == 0) ? '0' : (char)((10 - luhmSum % 10) + '0');
                  }



             //   測試代碼


          public class ResTest {
          public static void main(String[] args) {
             String reg = "18632116655";
             String data = JsonUtil.toJson(reg);
             String post = HttpClient.post("http://192.168.199.127:8067/openapi/rest/hometop/homeinfo", AESUtil.encrypt(data));
             System.out.println(post);
             System.out.println(AESUtil.decrypt(post));
          }
          }











          /**
          * author:qiaoyongjun
          * StrNo:用戶輸入的身份證件號碼
          * _id:用來承載錯誤信息的控件ID號,用來進行友好提示
          *判斷身份證號碼格式函數
          *公民身份號碼是特征組合碼,
          *排列順序從左至右依次為:六位數字地址碼,八位數字出生日期碼,三位數字順序碼和一位數字校驗碼
          *如果驗證通過 返回 true
          */
          function isChinaIDCard(StrNo, _Id) {
          var error = document.getElementById(_Id);
          StrNo = StrNo.toString();
          if (StrNo.length == 15) {
          if (!isValidDate("19" + StrNo.substr(6, 2), StrNo.substr(8, 2),
          StrNo.substr(10, 2), _Id)) {
          return false;
          }
          } else if (StrNo.length == 18) {
          if (!isValidDate(StrNo.substr(6, 4), StrNo.substr(10, 2), StrNo
          .substr(12, 2), _Id)) {
          return false;
          }
          } else {
          error.innerHTML = "";
          error.innerHTML = "輸入的身份證號碼必須為15位或者18位!";
          return false;
          }
          if (StrNo.length == 18) {
          var a, b, c
          if (!isNumber(StrNo.substr(0, 17))) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼錯誤,前17位不能含有英文字母!";
          return false;
          }
          a = parseInt(StrNo.substr(0, 1)) * 7 + parseInt(StrNo.substr(1, 1))
          * 9 + parseInt(StrNo.substr(2, 1)) * 10;
          a = a + parseInt(StrNo.substr(3, 1)) * 5
          + parseInt(StrNo.substr(4, 1)) * 8
          + parseInt(StrNo.substr(5, 1)) * 4;
          a = a + parseInt(StrNo.substr(6, 1)) * 2
          + parseInt(StrNo.substr(7, 1)) * 1
          + parseInt(StrNo.substr(8, 1)) * 6;
          a = a + parseInt(StrNo.substr(9, 1)) * 3
          + parseInt(StrNo.substr(10, 1)) * 7
          + parseInt(StrNo.substr(11, 1)) * 9;
          a = a + parseInt(StrNo.substr(12, 1)) * 10
          + parseInt(StrNo.substr(13, 1)) * 5
          + parseInt(StrNo.substr(14, 1)) * 8;
          a = a + parseInt(StrNo.substr(15, 1)) * 4
          + parseInt(StrNo.substr(16, 1)) * 2;
          b = a % 11;
          if (b == 2) //最后一位為校驗位  
          {
          c = StrNo.substr(17, 1).toUpperCase(); //轉為大寫X  
          } else {
          c = parseInt(StrNo.substr(17, 1));
          }
          switch (b) {
          case 0:
          if (c != 1) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:1";
          return false;
          }
          break;
          case 1:
          if (c != 0) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:0";
          return false;
          }
          break;
          case 2:
          if (c != "X") {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:X";
          return false;
          }
          break;
          case 3:
          if (c != 9) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:9";
          return false;
          }
          break;
          case 4:
          if (c != 8) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:8";
          return false;
          }
          break;
          case 5:
          if (c != 7) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:7";
          return false;
          }
          break;
          case 6:
          if (c != 6) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:6";
          return false;
          }
          break;
          case 7:
          if (c != 5) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:5";
          return false;
          }
          break;
          case 8:
          if (c != 4) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:4";
          return false;
          }
          break;
          case 9:
          if (c != 3) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:3";
          return false;
          }
          break;
          case 10:
          if (c != 2) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼校驗位錯:最后一位應該為:2";
          return false;
          }
          }
          } else {//15位身份證號  
          if (!isNumber(StrNo)) {
          error.innerHTML = "";
          error.innerHTML = "身份證號碼錯誤,前15位不能含有英文字母!";
          return false;
          }
          }
          return true;
          }
          /**
          * 驗證身份證件中的日期是否合法有效
          * @param iY
          * @param iM
          * @param iD
          * @param _id
          * @return
          */
          function isValidDate(iY, iM, iD, _id) {
          if (iY > 2200 || iY < 1900 || !isNumber(iY)) {
          document.getElementById(_id).innerHTML = "";
          document.getElementById(_id).innerHTML = "輸入身份證號,年度" + iY + "非法!";
          return false;
          }
          if (iM > 12 || iM <= 0 || !isNumber(iM)) {
          document.getElementById(_id).innerHTML = "";
          document.getElementById(_id).innerHTML = "輸入身份證號,月份" + iM + "非法!";
          return false;
          }
          if (iD > 31 || iD <= 0 || !isNumber(iD)) {
          document.getElementById(_id).innerHTML = "";
          document.getElementById(_id).innerHTML = "輸入身份證號,日期" + iD + "非法!";
          return false;
          }
          return true;
          }
          /**
          * 驗證是否為數字
          * @param oNum
          * @return
          */
          function isNumber(oNum) {
          if (!oNum)
          return false;
          var strP = /^\d+(\.\d+)?$/;
          if (!strP.test(oNum))
          return false;
          try {
          if (parseFloat(oNum) != oNum)
          return false;
          } catch (ex) {
          return false;
          }
          return true;
          }
          posted @ 2014-12-21 22:09 藤本薔薇 閱讀(1767) | 評論 (0)編輯 收藏
          1.在JSP頁面中引入sun的核心標簽庫
               <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
          2.在JSP頁面中引入sun的函數標簽庫
              <%@ taglib uri="http://java.sun.com/jsp/jstl/functions"  prefix="fn"%>
          3.判斷是否為空
              <c:if test="${!empty map}">
              </c:if>
          4.判斷長度大于0
              <c:if test="${fn:length(map)>0}">
              </c:if>
          注:fn:length(obj),對于空對象也會返回0
          posted @ 2014-12-16 11:22 藤本薔薇 閱讀(535) | 評論 (0)編輯 收藏
           不想說技術,只想說——覺得iBATIS還是蠻強大的,嗯,就這句話
          posted @ 2014-12-04 18:12 藤本薔薇 閱讀(88) | 評論 (0)編輯 收藏



          $('input,select,textarea',$('form[name="my_form"]')).attr('readonly',true);
          posted @ 2014-11-28 20:12 藤本薔薇 閱讀(334) | 評論 (0)編輯 收藏
          SELECT to_char(add_months(sysdate,to_number(t.month)),'yyyymmddhhmmss')   from customer t
          posted @ 2014-11-27 09:28 藤本薔薇 閱讀(1612) | 評論 (0)編輯 收藏
              好多東西用是用了,一直沒有太細的研究過,很多細節方面就這么放過了
             比如說,<a href="#"> 與 <a href="javascript:void(0)">

              今天在頁面中間實現滑動標簽改變塊內容時發現
              <a href="#"> 這種寫法實現功能時,每次改變塊,頁面都會從頂部開始,明顯不合理

              <a href="javascript:void(0)">才會在當前位置改變塊內容
          posted @ 2014-11-24 11:03 藤本薔薇 閱讀(131) | 評論 (0)編輯 收藏
          僅列出標題
          共8頁: 上一頁 1 2 3 4 5 6 7 8 下一頁 
          主站蜘蛛池模板: 禹城市| 灵寿县| 民权县| 绥德县| 寿宁县| 昌黎县| 莱州市| 上林县| 隆化县| 宝应县| 枣庄市| 始兴县| 浦北县| 巧家县| 三亚市| 高州市| 寿宁县| 阿鲁科尔沁旗| 云阳县| 衡山县| 平邑县| 宁波市| 偏关县| 工布江达县| 四会市| 都昌县| 平利县| 湾仔区| 孟州市| 大厂| 正安县| 阿拉善左旗| 武宣县| 扎赉特旗| 北海市| 瑞丽市| 荃湾区| 高尔夫| 涞源县| 迁西县| 焉耆|