NutzCN Logo
问答 上传图片到数据库没成功
发布于 2114天前 作者 qq_9c525c7d 1293 次浏览 复制 上一个帖子 下一个帖子
标签:
	int timeout = 180 * 1000; // 单位毫秒
		Response response = Http.post2(innerurl+path, null, timeout);
        int len=0;  
        ByteArrayOutputStream bos=new ByteArrayOutputStream();  
        while((len=response.getStream().read(buffer))!=-1){  
            bos.write(buffer,0,len);  
        }  
        bos.flush();  
        buffer = bos.toByteArray(); 
        
		String condition = "insert into "+table+" ("+key+","+field+",LYID,FOLDERNAME,TYPE,CCWZ) values ('"+id+"',EMPTY_BLOB(),'"+file.getLyid()+"','"+file.getFlodername()+"','"+file.getType()+"','"+file.getCcwz()+"')";
		Sql sql = Sqls.create(condition);
		daoMiddle.execute(sql);
		String condition2 = "select "+field+" from "+table+" where "+key+"='"+id+"' for update";
		Sql sql2 = Sqls.create(condition2);
	    sql2.setCallback(new SqlCallback() {
	        public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
	            List<Map> list = new LinkedList<Map>();
	            while (rs.next()){
	            	pc = (oracle.sql.BLOB) rs.getBlob(1);
	            	OutputStream os = pc.setBinaryStream(1);
	            	try {
						os.write(buffer);
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}finally{
						try {
							os.close();
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
	            }
	            return list;
	        }
	    });
	    daoMiddle.execute(sql2);
3 回复

。。。 写个pojo行不行,看看新手入门行不行

第三方的库,写不成pojo

这跟是不是第三方库神马关系?

添加回复
请先登陆
回到顶部