mysql数据库 
表名:mat_picture 
字段:matno varchar 
    picture longblob 
程序如下: 
                  conn = Database.createOAConnect(); 
        sql = "insert into mat_picture(matno,picture) values(?,?)"; 
    pstm = conn.prepareStatement(sql); 
    //插入料号 
    pstm.setString(1, matno); 
    is = new FileInputStream(new File(filename)); 
    //插入图片 
    pstm.setBinaryStream(2,is,is.available()); 
    pstm.executeUpdate(); 
(其中filename为存图片的物理地址) 
但是报这个错误,不知道怎么解决: 
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 '{?R_???s?O??{?=????z?s?w?~wkf??>??,?g6??÷±n×??ü?·z??N–???c_?(N????ú{}???lt··' at line 1

解决方案 »

  1.   

    郁闷,我也是这样的问题,Delphi用MyDAC连接MySQL,存图片时保存就提示乱码。#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S蝳绯?D\\茄LA&蚖彎????獃糣S榕mX藟 U愊 諹x詶#u裭to9tHs湒楈X黩囦?g纽' at line 3'. Process TestPIC.exe (680)
    First chance exception at $7C812AEB. Exception class EMyError with message '
    #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S蝳绯?D\\茄LA&蚖彎????獃糣S榕mX藟 U愊 諹x詶#u裭to9tHs湒楈X黩囦?g纽' at line 3'. Process TestPIC.exe (680)