MySQL存圖片報錯
請教
@Test public?void?testWriteBlob()?throws?IOException{ Students?s=new?Students(1,"韓菱紗",?"女",?new?Date(),?"仙劍"); //先獲取照片文件??File.separator為文件9分隔符 File?f=new?File("d:"+File.separator+"xmm.jpg"); //獲得照片文件的輸入流 InputStream?input=new?FileInputStream(f); //創(chuàng)建一個Blod對象createBlob(arg1,arg2);第一個參數(shù)為從哪個輸入流讀取第二個參數(shù)為讀取的長度 //長度應(yīng)該為此輸入流的可用長度即input.available() Blob?image=Hibernate.getLobCreator(session).createBlob(input,?input.available()); //設(shè)置照片屬性 s.setPicture(image); //保存學(xué)生 session.save(s); }
報的錯誤是:ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\0\0\0\0\0萛0\0怽0\0\0\0\00221?\0\0\0\0\0\0P?\0\0\0\0\0\0d?\0\0\0\0' at line 1
這種錯誤搜都不好搜……
2016-08-30
中文亂碼了,項目設(shè)置為utf-8,數(shù)據(jù)庫連接的url設(shè)置為utf-8,數(shù)據(jù)庫設(shè)置為utf-8,三個統(tǒng)一就不會錯了。
2016-08-04
同樣的錯誤
2016-07-07
你的錯誤在sql語法上,要貼出你寫的sql語句才能知道,檢查你寫的sql第一行語句。