Blob CLOB区别

区别:

CLOB :使用char来保存数据。例如xml文件、文章或者较长的文字。

BLOB:就是使用二进制保存数据。例如保存位图、图片音乐。

联系:两者可以互相转换。或者直接用lob字段代替两者。

读取数据

  ResultSet rs = stmt.executeQuery("SELECT TOP 1 * FROM Test1");

  rs.next();

  Reader reader = rs.getCharacterStream(2);

  插入数据

  PreparedStatement pstmt = con.prepareStatement("INSERT INTO test1 (c1_id, c2_vcmax) VALUES (?, ?)");

  pstmt.setInt(1, 1);

  pstmt.setString(2, htmlStr);

  pstmt.executeUpdate();

  更新数据

  Statement stmt = con.createStatemet();

  ResultSet rs = stmt.executeQuery("SELECT * FROM test1");

  rs.next();

  Clob clob = rs.getClob(2);

  long pos = clob.position("dog", 1);

  clob.setString(1, "cat", len, 3);

  rs.updateClob(2, clob);

  rs.updateRow();

原文地址:https://www.cnblogs.com/Hei-po/p/6813386.html