// obtain an XQDataSource instance XQDataSource xqds = (XQDataSource) Class.forName("com.jsr225.xqj").newInstance(); // obtain a connection XQConnection con = xqds.getConnection("usr", "passwd"); // prepare an XQuery Expression String xqry = "for $i in fn:collection('dept') " + "where $i/deptname = %dname return count($i/employees)"; XQPreparedExpression expr = con,preparedExpression(xqry); // bind variable with value expr.bindString(new Qname("dname"), "engineering"); // execute the XQuery Expression XQResultSequence rs = expr.executeQuery(); // Consume results while (rs.next()) { System.out.printLn(rs.getInt()); } // clean up resources rs.close(); con.close(); |
欢迎光临 DIY编程器网 (http://diybcq.com/) | Powered by Discuz! X3.2 |