讀取簡單點,用到輸入輸出流。

2



3

4


5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22



23

24

25

26

27

28

29

下面是寫入CLOB

2

3

4

5

6



7

8



9

10

11

12



13

14

15

16

17

18

conn.setAutoCommit(false);//取消自動提交
需要被首先執(zhí)行
需要插入一條新的記錄時,可以像下面這樣:
1. 先取sequence的值
strSql = "select sequence(表中column的名字).nextval from dual";
pstm = this.conn.prepareStatement(strSql);
rs = pstm.executeQuery();
2. 插入一個空值的CLOB
insert into tableName t (t.CLOB_column, t.sequence) values(empty_clob(), id)
pstm.executeUpdate();
3. 把這一行鎖定,用select ...for update語句,然后在寫入
strSql = "select t.CLOB_column from tableName t where t.sequence= " + id + " for update";
pstm = this.conn.prepareStatement(strSql);
rs = pstm.executeQuery();
if (rs.next())
{
clob1= (oracle.sql.CLOB) rs.getClob(1);
fillClob(clob1, content);
}
rs.close();
conn.commit();//對應上面的那句
pstm.close();
更新一條記錄
1. 清空CLOB的內容
strSql = "update tableName t set t.CLOB_column = empty_clob() where t.id ='" + id + "'";
pstm = this.conn.prepareStatement(strSql);
pstm.executeUpdate();
2. 和插入新記錄一樣,需要用for update鎖定

2

3

4

5



6

7

8

9

10

11

12

13

14

15

16

17

18
