谁有把图片插入数据库并且读出来的代码!!! 配置:tomcat6.0 myeclip8.5 mysql数据库 图片为byte[]类型 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://robinsoncrusoe.javaeye.com/blog/798830 可是我用ssh模式做的啊 这句话是就JSP页面的getImage.action?book.ISBN=<s:property value="#onebook.ISBN"/>什么意思啊 4楼正解,自己到getImage.action里面去输出图片流 public void insertData(String filePath1, String tempStr1, String sql,String filename) { try { PreparedStatement pstmt = null; // String sql = ""; File file = new File(filePath1); InputStream photoStream = new FileInputStream(file); pstmt = con.prepareStatement(sql); pstmt.setString(2, filename); // 文件名 pstmt.setString(3, tempStrID); // 要插入的列 pstmt.setBinaryStream(1, photoStream, (int) file.length()); //图片文件的流 pstmt.executeUpdate(); System.out.println("写入文件"); pstmt.close(); // con.close(); } catch (Exception e) { e.printStackTrace(); } }我有一个,是用SQl数据库写的。楼主参考一下吧 批量修改JLabel字体 到底要学什么?程序员的竞争点在哪? applet显示图片问题,急!! 求助 读取一组 checkbox类 ??? 怎么样把一个自定义的类型的数据写入一个文件再按照这个类型读 'this'在'构造代码块'中也是'当前对象的意思? 我就是不明白JAVA为什么这么作做?怎么用着就觉得别扭呢? 各位测试自己的软件的速度,或某个功能块的速度一般用什么方法?互相交流一下 哪位大虾有enhydra的技术文档,给一份或提供线索。一定高分向送(66) 看看我的程序好吗?各位大侠! 怎么将页面上的数据转换到数据库中 请问如何在java swing table单元格增加个下拉框呢。
什么意思啊
public void insertData(String filePath1, String tempStr1, String sql,String filename) {
try {
PreparedStatement pstmt = null;
// String sql = "";
File file = new File(filePath1); InputStream photoStream = new FileInputStream(file); pstmt = con.prepareStatement(sql);
pstmt.setString(2, filename);
// 文件名
pstmt.setString(3, tempStrID);
// 要插入的列
pstmt.setBinaryStream(1, photoStream, (int) file.length());
//图片文件的流
pstmt.executeUpdate();
System.out.println("写入文件");
pstmt.close();
// con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
我有一个,是用SQl数据库写的。楼主参考一下吧