低手求救啊,关于一个查询access数据库中某数据是否存在的问题,我错在哪里??

zuoxxx 2006-05-09 09:29:46
我查询一个access数据库中的user表中的username

看看是否存在某个username

用了下面的语句:

ResultSet rs_3633=statement.executeQuery("select count(*) from user where username='"+name+"'");
int count=rs_3633.getInt(1);
if(count>0){
return "The username has existed,please try another one!";
}
else{
......
}

根据观察好象是错在int count=rs_3633.getInt(1);处啊
抛出的异常是:
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source)
at ServiceImpl.register(ServiceImpl.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

谁帮小弟分析解决一下啊,我太笨了.......改怎样才对呢?
呵呵
...全文
87 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
little06 2006-05-10
  • 打赏
  • 举报
回复
count=rs_3633.next();
少了这个
little06 2006-05-10
  • 打赏
  • 举报
回复
ResultSet rs_3633=statement.executeQuery("select count(*) from user where username='"+name+"'");
count=rs_3633.next();
int count=rs_3633.getInt(1);
if(count>0){
return "The username has existed,please try another one!";
}
else{
......
}

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧