public static void write(File file) throws Exception{
Class.forName("com.mysql.jdbc.Driver");
Connection co=DriverManager.getConnection("jdbc:mysql://localhost:3306/abs","root","");
String sql="insert into file (id,file) values (?,?)";
PreparedStatement pst=co.prepareStatement(sql);
pst.setInt(1, 1);
InputStream in=new FileInputStream(file);
pst.setBinaryStream(2, in, in.available());
pst.executeUpdate();
System.out.println("写入Ok!");
in.close();
pst.close();
co.close();
}
public static void main(String[] args) throws Exception{
File file=new File("E://a.jpg");
write(file);
}运行提示sql语句错误???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 '?kK ?????—!?Vé??è???é????????b???}???????k??±?a6????#é????Yé??'?è??Cé???' at line 1
Class.forName("com.mysql.jdbc.Driver");
Connection co=DriverManager.getConnection("jdbc:mysql://localhost:3306/abs","root","");
String sql="insert into file (id,file) values (?,?)";
PreparedStatement pst=co.prepareStatement(sql);
pst.setInt(1, 1);
InputStream in=new FileInputStream(file);
pst.setBinaryStream(2, in, in.available());
pst.executeUpdate();
System.out.println("写入Ok!");
in.close();
pst.close();
co.close();
}
public static void main(String[] args) throws Exception{
File file=new File("E://a.jpg");
write(file);
}运行提示sql语句错误???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 '?kK ?????—!?Vé??è???é????????b???}???????k??±?a6????#é????Yé??'?è??Cé???' at line 1
解决方案 »
- 请问谁做过在linux下用java开发串口通信程序,所用第三方jar包是rxtx
- 单个 boolean 使用 int 来表示,占 4 个字节,而 boolean 数组是使用 byte 数组来表示的。 ???
- 传递数组参数的问题
- 在对jtree编辑后如何保存
- java如何提取一个给定网址的最小域名?
- 关于调用的问题
- 谁有jsp记数器源码?
- overriding and overloading
- 我正在做一个线程池,请帮忙看看我的问题
- ???????JBuilder6中怎样解决中文问题?????????????????????????????
- java初学-新建时每次 都有句 package 什么的..
- for(;z<10;++z){} 这个是什么意思,z的初始值是????
sql语句??数据库中字段的类型
sql语句??数据库中字段的类型搞定了 把数据库的编码方式改成utf8就OK了