sql – 如何使用JDBC更新Oracle Clob

正常方式如下:
pStmt = conn.prepareStatement("SELECT DETAILS FROM PROGRAM_HISTORY WHERE id = 12");
    rset = pStmt.executeQuery();
    Clob detailsClob= rset.getClob(1);
    Writer writer = adapter.getCharacterOutputStream(detailsClob);
    writer.write("add more details"); 

    pStmt = conn.prepareStatement("UPDATE PROGRAM_HISTORY SET DETAILS = ? WHERE ID = 12");
    pStmt.setClob(1,detailsClob);
    pStmt.execute();

这有点复杂,是我不需要先阅读然后更新它的任何方式.就像更新varchar一样.

解决方法

不知道为什么你称之为“正常”的方式,但以下对我有用.

在更新之前,它不需要任何数据检索.

String value = "So long and thanks for all the fish";
StringReader reader = new StringReader(value);
pStmt = conn.prepareStatement("UPDATE PROGRAM_HISTORY SET DETAILS = ? WHERE ID = 12");
pStmt.setCharacterStream(1,reader,value.length();
pStmt.executeUpdate();

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...