Java Blob类型和String类型相互转换

  1. 1、String 转 Blob:  
  2.   
  3.     String content = "Hello World!";  
  4.   
  5.     Blob blob = Hibernate.createBlob(content.getBytes());  
  6.   
  7. 2、Blob 转 String:  
  8.   
  9.     Blob blob;  
  10.   
  11.     try{  
  12.          String content = new String(blob.getBytes((long)1, (int)blob.length()));  
  13.     } catch(SQLException e) {  
  14.          e.printStackTrace();  
  15.     } 
posted @ 2016-05-23 17:36  微软小菜鸟  阅读(12106)  评论(0编辑  收藏  举报