java.sql.SQLException:找不到数据 [英] java.sql.SQLException: No data found
问题描述
它是Ajax jsp页面的一部分
Its a part of Ajax jsp page
while(rs.next())
{
System.out.println(rs.getString("Flat_No"));
buffer=buffer+"<option value='"+rs.getString("Flat_No")+"'>"+rs.getString("Flat_No")+"</option>";
}
Flat_No
共有4个值,它打印的第一个值是控制台和aftr,我的jsp页面上出现错误java.sql.SQLException:找不到数据
There are total 4 values in Flat_No it printing first values in console and aftr that i m getting error on my jsp page "java.sql.SQLException: No data found "
推荐答案
这是一个通过糟糕的JDBC-ODBC桥驱动程序使用MS Access数据库并从结果集中多次检索相同数据时的典型错误。您需要检索一次数据并将其分配给变量并使用该变量多次。
This is a typical error when using the MS Access database through the poor JDBC-ODBC bridge driver and retrieving the same data more than once from the result set. You need to retrieve the data once and assign it to a variable and use the variable multiple times instead.
while (rs.next()) {
String flatNo = rs.getString("Flat_No");
buffer += "<option value='" + flatNo + "'>" + flatNo + "</option>";
}
不相关对于具体问题,在JSP文件中执行此操作是坏主意。另请参阅使用MVC和DAO模式在JSP页面中以HTML格式显示JDBC ResultSet 示例如何以正确的方式进行。
Unrelated to the concrete problem, doing this in a JSP file is a bad idea. See also Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern for another concrete example how to do it the proper way.
这篇关于java.sql.SQLException:找不到数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!