import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;public class test {
public static void main(String[] args) {
create();
}

static void create(){
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try{
conn = JDBCUtils.getConnection();
String sql = "insert into blob(data) values(?)";
ps = conn.prepareStatement(sql);
File file = new File("02.jpg");
InputStream in = new BufferedInputStream(new FileInputStream(file));
ps.setBinaryStream(1, in, file.length());

int i = ps.executeUpdate();
in.close();
System.out.println(i);
}catch(Exception e){
e.printStackTrace();
}finally{
JDBCUtils.free(rs, ps, conn);
}
}
}
报错信息:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'blob(data) values(_binary'??\0JFIF\0\0`\0`\0\0?\0C\0
' at line 1
Mysql和Eclipse的字符集都是“GBK”
问量出在哪里呢?