Grails上傳文件,默認(rèn)字段長度小的問題總結(jié)

          1.       存在1Domain class Profile,其中有個字段是存放相片的

          class Profile {

              
          //Profile is owned by User
              
          //unidirectional relationship, profile can load user 
              static belongsTo = User
              
              
          //binary data in byte[]
              byte[] photo

          static mapping = {
                  columns {
                      photo type:
          'blob'
                  }
               }

          默認(rèn)情況下,byte[]數(shù)組在mysql下建立的字段是tinyblob,當(dāng)上傳大點的圖片時,就會出現(xiàn)問題


          解決辦法:運行程序后,手動將數(shù)據(jù)庫的tinyblob 改成 longblob,然后

          然后,在datasouce.groovy中,把create-drop改成update,就可以了

          development {
             dataSource {
              dbCreate 
          = "update" // one of 'create', 'create-drop','update'
                      
          //url = "jdbc:hsqldb:mem:devDB"
                      driverClassName = "com.mysql.jdbc.Driver"
                      username 
          = "root"
                      password 
          = "dens"
                      url 
          = "jdbc:mysql://localhost:3306/hubbub?useUnicode=true&characterEncoding=utf8"
                  }
          }

          posted on 2012-02-14 17:18 想飛就飛 閱讀(603) 評論(0)  編輯  收藏 所屬分類: Groovy/Grails

          公告


          導(dǎo)航

          <2012年2月>
          2930311234
          567891011
          12131415161718
          19202122232425
          26272829123
          45678910

          統(tǒng)計

          常用鏈接

          留言簿(13)

          我參與的團隊

          隨筆分類(69)

          隨筆檔案(68)

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 平昌县| 武陟县| 宁津县| 巴林右旗| 怀仁县| 南华县| 德化县| 确山县| 沁阳市| 斗六市| 大名县| 张家港市| 雅江县| 汕尾市| 科技| 曲沃县| 会泽县| 萍乡市| 胶南市| 余江县| 海淀区| 怀仁县| 玛纳斯县| 普兰县| 宜良县| 康乐县| 阿巴嘎旗| 翁牛特旗| 临潭县| 长春市| 甘孜县| 泽州县| 内黄县| 夹江县| 莱阳市| 乌鲁木齐市| 稷山县| 克什克腾旗| 渝中区| 洪洞县| 康平县|