我想在java中执行简单的xquery。但我得到例外
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.xml.xquery.XQException:
XQJFOS017 - Can not call getItemType() when Forward Only Sequences is not positioned on an item.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
我的依赖
<groupId>org.basex</groupId>
<artifactId>basex</artifactId>
<version>7.3.1</version>
<groupId>net.xqj</groupId>
<artifactId>basex-xqj</artifactId>
<version>1.4.0</version>
我的豆子
@Bean(name = "baseXDataSource")
public XQDataSource xqDataSource() throws XQException {
XQDataSource ds = new BaseXXQDataSource();
ds.setProperty("serverName", "localhost");
ds.setProperty("port", "1984");
ds.setProperty("user", "admin");
ds.setProperty("password", "admin");
ds.setProperty("databaseName", "2016");
return ds;
}
我的代码
XQConnection conn = baseXDataSource.getConnection("admin", "admin");
XQPreparedExpression expr = conn.prepareExpression("123");
XQResultSequence result = expr.executeQuery();
return result.getItemType().toString();
我尝试执行的任何 xquery 都会给出相同的结果。怎么了?谢谢!