我现在贴上一个读、和写的ORACLE的存取过程 create procedure sp_eml_read_content_html (in_row_id IN String,offset in integer, buf out String) AS clob_locator CLOB; total_amount INTEGER; read_offset INTEGER := offset; buffer VARCHAR2(2048); error_msg VARCHAR2(255); BEGIN SELECT html INTO clob_locator FROM eml_message_content WHERE message_id = in_row_id; --DBMS_OUTPUT.PUT_LINE('1'); total_amount := 1024; --DBMS_LOB.GETLENGTH(clob_locator); DBMS_OUTPUT.PUT_LINE('2:'||to_char(total_amount)); DBMS_LOB.READ(clob_locator, total_amount, read_offset, buffer); buf:=substr(buffer,1,total_amount); EXCEPTION WHEN NO_DATA_FOUND THEN error_msg := 'no more data'; DBMS_OUTPUT.PUT_LINE(error_msg); WHEN OTHERS THEN --error_msg := 'unspecified error occured'; error_msg := sqlerrm(sqlcode); DBMS_OUTPUT.PUT_LINE(error_msg);END; / create procedure sp_eml_save_content_html(id in String,html in varchar2,offset in integer) as html_locator_var clob; amount_var integer; offset_var integer; html_buffer_var varchar(2048); begin amount_var:=length(html); offset_var:=offset; html_buffer_var:=html; select html into html_locator_var from eml_message_content where message_id=id for update; DBMS_LOB.WRITE(html_locator_var,amount_var,offset_var,substr(html_buffer_var,1,amount_var)); commit; end;/用JDBC调用存储过程。就行,注意长度和每次读取的缓冲
String content ="";
clob = rs.getCLOB(2);
Reader instream = clob.getCharacterStream();
BufferedReader br = new BufferedReader(instream);while ((str = br.readLine()) != null) {
content = content + str ;
}
不行,如果插进去的是rtf文件的内容,就不能转换成string。
能不能说的更详细一些,或者举个例子,多谢了
能不能说的更详细一些,或者举个例子,多谢了
[email protected]
create procedure sp_eml_read_content_html (in_row_id IN String,offset in integer, buf out String)
AS
clob_locator CLOB;
total_amount INTEGER;
read_offset INTEGER := offset;
buffer VARCHAR2(2048);
error_msg VARCHAR2(255); BEGIN
SELECT html INTO clob_locator FROM eml_message_content
WHERE message_id = in_row_id;
--DBMS_OUTPUT.PUT_LINE('1');
total_amount := 1024; --DBMS_LOB.GETLENGTH(clob_locator); DBMS_OUTPUT.PUT_LINE('2:'||to_char(total_amount)); DBMS_LOB.READ(clob_locator, total_amount, read_offset, buffer); buf:=substr(buffer,1,total_amount); EXCEPTION
WHEN NO_DATA_FOUND
THEN
error_msg := 'no more data';
DBMS_OUTPUT.PUT_LINE(error_msg); WHEN OTHERS THEN
--error_msg := 'unspecified error occured';
error_msg := sqlerrm(sqlcode);
DBMS_OUTPUT.PUT_LINE(error_msg);END;
/
create procedure sp_eml_save_content_html(id in String,html in varchar2,offset in integer)
as
html_locator_var clob;
amount_var integer;
offset_var integer;
html_buffer_var varchar(2048);
begin
amount_var:=length(html);
offset_var:=offset;
html_buffer_var:=html; select html into html_locator_var from eml_message_content where message_id=id for update;
DBMS_LOB.WRITE(html_locator_var,amount_var,offset_var,substr(html_buffer_var,1,amount_var));
commit;
end;/用JDBC调用存储过程。就行,注意长度和每次读取的缓冲