试用期求助:[Microsoft][ODBC 驱动程序管理器]无效的描述器索引(200分)

  • 主题发起人 主题发起人 ff_ff
  • 开始时间 开始时间
F

ff_ff

Unregistered / Unconfirmed
GUEST, unregistred user!
Access数据库,
[Microsoft][ODBC 驱动程序管理器]无效的描述器索引
错误.
在access中,select count(*) from question;
对吗?
public class ComputeServlet extends HttpServlet{

public voiddo
Get(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
System.out.println("in ComputeServlet");
int count = 0;
ConnAccess conn = null;
try{

conn = new ConnAccess();
String sql = "select count(*) from question";
ResultSet rs = conn.Query(sql);
System.out.println(sql);
rs.next();
count = rs.getInt(0);// 这里出错.
}catch(Exception e){
e.printStackTrace();
}
try{
conn.close();
}catch(Throwable ee){
ee.printStackTrace();
}
System.out.println(count);

}
public voiddo
Post(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
do
Get(request, response);
}
}
 
c#吧. 你连接数据库的字符串在那里?
 
是java不是c#
"select count(*) from question";选出一条记录后,怎么取,
用rs.getInt(0);
select count(id) as max from question
或者用rs.getInt("max");都出以上的错误?
 
算出来了
ConnAccess con = new ConnAccess();
ResultSet rs = con.Query("select count(id) as max from question");
rs.next();
count = rs.getInt("max");
哈哈
 
散分了。大家一人分几分了。
 
接受答案了.
 
后退
顶部