[Microsoft] [ODBC驱动程序管理器]无效的光标状态 [英] [Microsoft][ODBC Driver Manager] Invalid cursor state

查看:111
本文介绍了[Microsoft] [ODBC驱动程序管理器]无效的光标状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在尝试访问Microsoft Acess数据库,但出现以下错误:

Hello

I am trying to access a Microsoft acess database and i get the following error:

[Microsoft][ODBC Driver Manager] Invalid cursor state



我的代码如下



My code is as following

import java.sql.*;


class Test
{
 public static void main(String[] args)
 {
 try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:Cont","","");
Statement s = con.createStatement();
ResultSet rset = s.executeQuery("SELECT * FROM Customer");
//ResultSet rset = s.getResultSet();

while(rset.next());
{
	System.out.exp.printStackTrace(rset.getString("ID") +" " + rset.getString("Name") +" " +
			rset.getString("Email") + " " +
			rset.getInt("Comments")); 
}

 }
 catch (ClassNotFoundException exp) {
System.err.println(exp);

 }
 catch(SQLException exp)
 {
	 System.err.println(exp);
 }
 }
}



任何帮助将不胜感激

谢谢



Any help would be appreciated

Thanks

推荐答案

看看
Take a look at this[^] thread where someone had the same error.

Note particularly the while loop and the couple of lines before it. (the beforefirst() call)

From this I have gathered that the cursor gets positioned past the end of the result set when the query is executed.


这篇关于[Microsoft] [ODBC驱动程序管理器]无效的光标状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆