读书人

java念数据库中导入图片

发布时间: 2014-01-23 14:48:04 作者: rapoo

java想数据库中导入图片
报错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后面是一通乱码


Connection conn=null;
PreparedStatement ps=null;
ResultSet rs = null;
try{
//建立连接
conn=TestUtil.getConnection();
//创建语句
String sql="insert into table2(big1) values(?)";
ps=(PreparedStatement) conn.prepareStatement(sql);
File file=new File("t5 .jpg");
BufferedInputStream in=new BufferedInputStream(new FileInputStream(file));

ps.setBinaryStream(1, in,(int)file.length());

int i=ps.executeUpdate();
in.close();
System.out.println(i);


}finally{
TestUtil.free(rs, ps, conn);
}
是红色的那句话有问题吗?请问怎么解决啊?应该不是关键字的问题。

读书人网 >Java Web开发

热点推荐