用java怎么把文件上传到mysql数据库
用java怎么把文件上传到mysql数据库,是直接传到数据库,然后需要从数据库将文件下载下来
------解决方案--------------------
conn = JdbcUtils.getConnection();
// conn = JdbcUtilsSing.getInstance().getConnection();
// 3.创建语句
String sql = "insert into blob_test(big_bit) values (?) ";
ps = conn.prepareStatement(sql);
File file = new File("IMG_0002.jpg");
InputStream in = new BufferedInputStream(new FileInputStream(file));
ps.setBinaryStream(1, in, (int) file.length());
// 4.执行语句
int i = ps.executeUpdate();
in.close();