PostgreSQL:获取函数的结果

时间:2012-03-01 12:45:30

标签: java xml postgresql

我有一个PostgreSQL Funktion,它返回一个XML,我的表的整个信息都是。

这是我的功能:

/* get all cat names */
create function cat_names() returns xml as $$
select to_xml('select name FROM cat_Infos;');
$$ language sql; 

得到结果我做了下面的事情:

ResultSet rs = sql.executeQuery("select cat_names()");
while (rs.next()) {
   // This is where I actually thought  that I could pass the XML I get, to my DOMParser. 
   //  I thought about something like this :
   DOMParser dom = new DOMParser();
   dom.setImputString(//Xml I get from the resultset)
}

问题是,我实际上不知道如何从ResultSet中获取Xml。

1 个答案:

答案 0 :(得分:0)

你应该可以使用

 String xml = rs.getString(1)

获取XML字符串