当前位置: 技术问答>java相关
请问这小段代码有什么问题?distinct & SQLException
来源: 互联网 发布时间:2015-06-14
本文导语: try { rs = st.executeQuery("select distinct 分类 from 表"); while(rs.next()) { String type = rs.getString(1); if (type == null) type = "(未分类)...
try {
rs = st.executeQuery("select distinct 分类 from 表");
while(rs.next()) {
String type = rs.getString(1);
if (type == null) type = "(未分类)";
classes.addLast(type);
}
}
catch (SQLException e) {
System.out.println(e);
}
运行时:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
程序不退出。
去掉 SQL 语句中的 distinct 则没有问题,为何?
ps, 数据库用的是Access,使用JDBC-ODBC,但不建数据源
高手请指教。多谢!
rs = st.executeQuery("select distinct 分类 from 表");
while(rs.next()) {
String type = rs.getString(1);
if (type == null) type = "(未分类)";
classes.addLast(type);
}
}
catch (SQLException e) {
System.out.println(e);
}
运行时:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
程序不退出。
去掉 SQL 语句中的 distinct 则没有问题,为何?
ps, 数据库用的是Access,使用JDBC-ODBC,但不建数据源
高手请指教。多谢!
|
我用Sybase怎么没问题,是不是Access不支持。
|
rs 如何设置的?
|
我的也是出现这种问题:
不过是中文的:非法的游标状态
不过是中文的:非法的游标状态
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。