//获取连接 Connection conn JDBCUtils.getConnection(); String sql insert into customers(name,email,birth,photo)values(?,?,?,?) PreparedStatement ps conn.prepareStatement(sql); //java fhadmin.org // 填充占位符 ps.setString(1, 张强 ps.setString(2, 123 126.com ps.setDate(3, new Date(new java.util.Date().getTime())); // 操作Blob类型的变量 FileInputStream fis new FileInputStream( xhq.png ps.setBlob(4, fis); ps.execute(); fis.close(); JDBCUtils.closeResource(conn, ps);3 修改数据表中的Blob类型字段
Connection conn JDBCUtils.getConnection(); String sql update customers set photo ? where id ? PreparedStatement ps conn.prepareStatement(sql); //java fhadmin.org // 填充占位符 // 操作Blob类型的变量 FileInputStream fis new FileInputStream( coffee.png ps.setBlob(1, fis); ps.setInt(2, 25); ps.execute(); fis.close(); JDBCUtils.closeResource(conn, ps);4 从数据表中读取大数据类型
//java fhadmin.org String sql SELECT id, name, email, birth, photo FROM customer WHERE id ? conn getConnection(); ps conn.prepareStatement(sql); ps.setInt(1, 8); rs ps.executeQuery(); if(rs.next()){ Integer id rs.getInt(1); String name rs.getString(2); String email rs.getString(3); Date birth rs.getDate(4); Customer cust new Customer(id, name, email, birth); System.out.println(cust); //读取Blob类型的字段 Blob photo rs.getBlob(5); InputStream is photo.getBinaryStream(); OutputStream os new FileOutputStream( c.jpg byte [] buffer new byte[1024]; int len while((len is.read(buffer)) ! -1){ os.write(buffer, 0, len); JDBCUtils.closeResource(conn, ps, rs); if(is ! null){ is.close(); if(os ! null){ os.close(); }
?
域名 市场上的交易其实一直以来都很频繁,尤其是精品大米的交易更是如此,而且一...
-更多关于数智化转型、数据中台内容请加入 阿里云数据中台交流群—数智俱乐部 和...
TOP云 (west.cn)12月13日消息,上周谐音“霸麒麟”的三数字 域名 870.vip在TOP...
TOP云 (west.cn)4月26日消息,昨日创新工场宣布,将成立投资文化内容与体育方...
日前,为进一步宣贯《云计算服务安全评估办法》,推动云计算服务安全评估工作,...
7月14日,阿里云新品发布会上,阿里云混合云产品总监谢宁正式宣布 阿里云混合云 ...
为什么要写这类文章 作为一个程序员,代码能力毋庸置疑是非常非常重要的,就像现...
前言:我们都知道HashMap是线程不安全的,在多线程环境中不建议使用,但是其线程...
如何很大程度地为你的解决方案提高效率并降低成本?优化的架构很重要,选择正确的...
一个企业可以注册多少 域名 ?一个企业可以注册的域名数量没有限制,很多企业为...