错误:找不到符号结果集 [英] error: cannot find symbol resultset
问题描述
我真的很固执于此...我正在尝试将结果集转换为字符串,这是我的代码:
QueryExecution qExec = QueryExecutionFactory.create(s, ds) ;
ResultSet rs = qExec.execSelect() ;
//String x=rs.toString();
String[] arr = null;
while (rs.next()) {
String em = (String)rs.getString(0);
arr = em.split("\n");
for (int i =0; i < arr.length; i++){
subjectoutput.setText(arr[i]);
}
}
它给出了错误:
JavaApplication2.java:137: error: incompatible types
while (rs.next()) {
^
required: boolean
found: QuerySolution
JavaApplication2.java:138: error: cannot find symbol
String em = (String)rs.getString(0);
^
symbol: method getString(int)
location: variable rs of type ResultSet
2 errors
我的查询结果是这样:
----------------------------
| x
================================================
| <<SEMA-CR-3-4MHV9RJ@bounce.oracle-mail.com>> |
------------------------------------------------
您似乎正在尝试使用ResultSet
,就好像它是来自JDBC一样.但是您在此处使用 Jena ARQ .这不是JDBC实现,也不遵循该API. QueryExecution
是此处 ,并且ResultSet
是此处.
对于此ResultSet
对象,应调用hasNext()
以查看是否还有另一条记录,并调用next()
来获取该记录.因此,您的循环可能看起来像这样:
while (rs.hasNext()) {
QuerySolution qs = rs.next();
... // Do something with qs
}
ResultSet.getString(int)
是JDBC函数,在ResultSet
或QuerySolution
上都没有这样的函数,因此我无法确切告诉您如何从结果集中获取所需的信息.>
I am really stuck at this...I am trying to convert Result Set into string and this is my code :
QueryExecution qExec = QueryExecutionFactory.create(s, ds) ;
ResultSet rs = qExec.execSelect() ;
//String x=rs.toString();
String[] arr = null;
while (rs.next()) {
String em = (String)rs.getString(0);
arr = em.split("\n");
for (int i =0; i < arr.length; i++){
subjectoutput.setText(arr[i]);
}
}
and it gives error:
JavaApplication2.java:137: error: incompatible types
while (rs.next()) {
^
required: boolean
found: QuerySolution
JavaApplication2.java:138: error: cannot find symbol
String em = (String)rs.getString(0);
^
symbol: method getString(int)
location: variable rs of type ResultSet
2 errors
my query result is this:
----------------------------
| x
================================================
| <<SEMA-CR-3-4MHV9RJ@bounce.oracle-mail.com>> |
------------------------------------------------
It looks like you're trying to use ResultSet
as if it were from JDBC. But you're using Jena ARQ here. This isn't a JDBC implementation and it doesn't follow that API. QueryExecution
is here, and ResultSet
is here.
For this ResultSet
object, you should call hasNext()
to see if there is another record, and next()
to fetch the record. So your loop might look more like this:
while (rs.hasNext()) {
QuerySolution qs = rs.next();
... // Do something with qs
}
ResultSet.getString(int)
is a JDBC function, and there's no such function on either ResultSet
or QuerySolution
, so I couldn't tell you exactly how to get the information that you want out of the result set.
这篇关于错误:找不到符号结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!