在执行以下代码的黑莓sqlite中,我得到异常“无法准备已经准备好的语句”
public Department[] getDepartment()
{
Department[] department = null;
try
{
database = DatabaseFactory.open(myURI);
Statement st = database.createStatement("SELECT code, name, status FROM Department");
st.prepare();
Cursor c = st.getCursor();
Row r;
int i = 0;
department = new Department[i];
while(c.next())
{
r = c.getRow();
i++;
Department dept = (Department) r.getObject(i);
department[i] = dept;
}
st.close();
database.close();
}
catch ( Exception e )
{
System.out.println("Exception occured --------------" +e.getMessage());
}
return department;
}
任何人都知道这个的解决方案
答案 0 :(得分:0)
只有在未准备好声明时才需要st.prepare()
,这意味着:
在这种情况下,情况都不是这样,因此该陈述是多余的。
<强>参考强>