oracle blob過濾

bei_fang_du_lang發表於2017-09-30
        private static String hexString = "0123456789ABCDEF";

	private static String encode(String str) {
		try{
			// 根據預設編碼獲取位元組陣列
			byte[] bytes = str.getBytes("UTF-8");
			StringBuilder sb = new StringBuilder(bytes.length * 2);
			// 將位元組陣列中每個位元組拆解成2位16進位制整數
			for (int i = 0; i < bytes.length; i++) {
				sb.append(hexString.charAt((bytes[i] & 0xf0) >> 4));
				sb.append(hexString.charAt((bytes[i] & 0x0f) >> 0));
			}
			return sb.toString();
		}catch(Exception e){
			e.printStackTrace();
		}
		return "";
	}
                if(n_content!=null&&!n_content.equals("")){
			n_content = encode(n_content);
			sql.append(" AND dbms_lob.instr(N_CONTENT,'"+n_content+"',1,1)<>0 ");
		}


相關文章