将xml文件写入字符串然后插入到oracle db groovy中

时间:2016-03-15 05:34:49

标签: xml oracle groovy

您好,我的xml文件名为test.xml,内容如下:

  <?xml version="1.0" encoding="UTF-8" ?> 
  <ns:AccountQueryPage_Output xmlns:ns="urn:crmondemand/ws/ecbs/account/">
  <ListOfAccount xmlns="urn:/crmondemand/xml/Account/Data" lastpage="true">
  <Account>
  <Id>CCC-TEST01</Id> 
  <AccountName>John Smith Pty Ltd</AccountName> 
  </Account>
  </ListOfAccount>
  </ns:AccountQueryPage_Output>

我需要使用groovy

将内容加载到名为SCOTT.RESP的oracle表中
import groovy.sql.Sql

String fileContents = new File('C:\\Documents\\test.xml').getText('UTF-8')
println fileContents

sql = Sql.newInstance("jdbc:oracle:thin:@localhpst:1521/orcl.com", "SCOTT", "Password","oracle.jdbc.pool.OracleDataSource")
sql.execute("""INSERT INTO SCOTT.RESP VALUES(fileContents)""")    

我收到错误

ORA-00984:此处不允许列

(从错误行号中减去17以考虑标准导入) java.sql.SQLSyntaxErrorException:ORA-00984:此处不允许列

你知道我为什么会收到这个错误吗?

提前致意并表示感谢

1 个答案:

答案 0 :(得分:0)

我在oracle技术论坛上找到了答案

https://community.oracle.com/message/10271899

谢谢

相关问题