oracle clob 数据类型的读取

rs = pstmt.executeQuery();
java.sql.Clob clob = null;
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String,String> map = new HashMap<String,String>();
if (rs.next()) {
	clob = ((OracleResultSet)rs).getCLOB("DESCRIPTION");
	InputStream input = clob.getAsciiStream();
	int len = (int)clob.length();
	byte[] by = new byte[len];
	int i ;
	while(-1 != (i = input.read(by, 0, by.length))) {
		input.read(by, 0, i);
	}
	String q = new String(by);
	System.out.println("clob:"+q);
	map.put("id", rs.getString("id"));
	map.put("projectId", q.substring(0, q.indexOf("|")));
	System.out.println("项目id:"+q.substring(0, q.indexOf("|")));
	map.put("sellerId", q.substring(q.indexOf("|")+1, q.length()));
	System.out.println("卖家id:"+q.substring(q.indexOf("|")+1, q.length()));
	map.put("quantityOffered", String.valueOf(rs.getInt("QUANTITY_OFFERED")));//碳量
	map.put("endDate", DateUtils.parseDate2String(rs.getDate("END_DATE"),DateUtils._DATE_SHORT));
	map.put("contractSize", String.valueOf(rs.getFloat("CONTRACT_SIZE")));
	
	System.out.println("碳量:"+String.valueOf(rs.getInt("QUANTITY_OFFERED")));
	System.out.println("到期时间:"+DateUtils.parseDate2String(rs.getDate("END_DATE"),DateUtils._DATE_SHORT));
	list.add(map);
}


 

你可能感兴趣的:(oracle,Date,String,list,input,byte)