問題描述
我需要將 XML 文件內容寫入 oracle 數據庫,其中列是 CLOB 數據類型.我該怎么做?
I need to write an XML file content into oracle database where the column is of CLOB datatype. How will I do that?
推薦答案
已過時請參閱下面 Lukas Eder 的回答.
OUTDATED See Lukas Eder's answer below.
大約 100 行代碼 ;-) 這是一個例子.
要點:與其他 JDBC 驅動程序不同,Oracle 的驅動程序不支持使用 Reader
和 InputStream
作為 INSERT
.相反,您必須 SELECT
CLOB
列 FOR UPDATE
然后寫入 ResultSet
The main point: Unlike with other JDBC drivers, the one from Oracle doesn't support using Reader
and InputStream
as parameters of an INSERT
. Instead, you must SELECT
the CLOB
column FOR UPDATE
and then write into the ResultSet
我建議您將此代碼移動到輔助方法/類中.否則,它將污染您的其余代碼.
I suggest that you move this code into a helper method/class. Otherwise, it will pollute the rest of your code.
這篇關于Java:如何將 CLOB 插入 oracle 數據庫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!