java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态 5
数据库:表:xxglxt列:noname内容:3532007nonono程序源文件:importjava.sql.Connection;importjava.sql.Dr...
数据库:
表:xxglxt
列:no name
内容:3532007 nonono
程序源文件:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
* @author hanlong
*/
public class DataBase
{
Connection con=null;
Statement sta;
ResultSet res;
public DataBase()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.print("1");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// java.sql.DriverManager.registerDriver(new org.gjt.mm.mysql.Driver());
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E:/我的ECLIPSE/临时文件夹/xxglxt.mdb";
String user=null;
String password=null;
try {
con=DriverManager.getConnection(url,user,password);
System.out.print("2");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
sta=con.createStatement();
System.out.print("3");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String sql="select no from xxglxt";
try {
res=sta.executeQuery(sql);
System.out.print("4");
System.out.print(res.getString(0));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String []args) throws ClassNotFoundException, SQLException
{
new DataBase();
}
}
输出:
1234java.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.SQLGetDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at DataBase.<init>(DataBase.java:54)
at DataBase.main(DataBase.java:64)
请问各路神仙,我哪里错了??? 展开
表:xxglxt
列:no name
内容:3532007 nonono
程序源文件:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
* @author hanlong
*/
public class DataBase
{
Connection con=null;
Statement sta;
ResultSet res;
public DataBase()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.print("1");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// java.sql.DriverManager.registerDriver(new org.gjt.mm.mysql.Driver());
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E:/我的ECLIPSE/临时文件夹/xxglxt.mdb";
String user=null;
String password=null;
try {
con=DriverManager.getConnection(url,user,password);
System.out.print("2");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
sta=con.createStatement();
System.out.print("3");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String sql="select no from xxglxt";
try {
res=sta.executeQuery(sql);
System.out.print("4");
System.out.print(res.getString(0));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String []args) throws ClassNotFoundException, SQLException
{
new DataBase();
}
}
输出:
1234java.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.SQLGetDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at DataBase.<init>(DataBase.java:54)
at DataBase.main(DataBase.java:64)
请问各路神仙,我哪里错了??? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询