Java操作DB2 XML数据实践

来源:中国IT实验室 作者:熔岩 2008-05-07 出处:pcdog.com

db2  java  oracle  xml  数据库  
上一页 1 2 3 
         * 查询xml列数据,用于验证
         *
         * @throws SQLException
         */
        public static void testQueryXMLColumn() throws SQLException {
            String query_sql = "SELECT INFO FROM Customer";
            Connection conn = DBUtils.makeConnection();
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(query_sql);
            StringBuffer xmls = new StringBuffer();
            while (rs.next()) {
                xmls.append(rs.getString(1)).append("\n");
            }
            System.out.println(xmls.toString());
            stmt.close();
            conn.close();
        }

        /**
         * 测试入口,方法组调用
         *
         * @param rags
         * @throws Exception
         */
        public static void main(String rags[]) throws Exception {
            testDropXMLTable();
            testCreateXMLTable();
            testInsertXMLTable();
            testQueryXMLTable();
            testUpdateXMLTable();
            testQueryXMLColumn();
        }
    }

    三、运行结果

    <out xmlns="http://posample.org"><name>Robert Shoemaker</name></out>

    <customerinfo xmlns="http://posample.org" Cid="1002"><name>Jim Noodle</name><addr country="Canada"><street>1150 Maple Drive</street><city>Newtown</city><prov-state>Ontario</prov-state><pcode-zip>Z9Z 2P2</pcode-zip></addr><phone type="work">905-555-7258</phone></customerinfo>


    Process finished with exit code 0


    呵呵,终于看到运行结果了。


更多内容请看PCdog.com--Web开发  开发应用专题
上一页 1 2 3 
上一篇:IBM DB2数据库中应当如何更新执行计划
下一篇:在DB2数据库中很难理解的catalog单词