java.sql.SQLException:[Microsoft] [ODBC驱动程序管理器]无效的描述符索引 [英] java.sql.SQLException:[Microsoft][ODBC Driver Manager] Invalid descriptor index

查看:113
本文介绍了java.sql.SQLException:[Microsoft] [ODBC驱动程序管理器]无效的描述符索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码

try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:access");
    String sql = "Select * from table";
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery( sql );
    ResultSetMetaData md = rs.getMetaData();
    int columns = md.getColumnCount();
    for (int i = 1; i <= columns; i++) {
        columnNames.addElement( md.getColumnName(i) );
    }
    while (rs.next()) {
        Vector row = new Vector(columns);
        for (int i = 1; i <= columns; i++){
            row.addElement( rs.getObject(i) );
        }
        data.addElement( row );
    }
    rs.close();
    stmt.close();
}catch(Exception e){
    System.out.println(e);
}

它显示:

java.sql.SQLException:[Microsoft][ODBC Driver Manager] Invalid descriptor index

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

我有相同的确切错误,这是出于Delphi的ODBC Express驱动程序造成的.

I have had the same exact error, this out of an ODBC Express Driver for Delphi.

我找到的解决方法是:

将varchar(max)和或varbinary(max)字段放在选择查询的末尾. (表定义中的顺序无关紧要.)

Place your varchar(max) and or varbinary(max) fields at the end of your select Query. (Order in the table definition doesn't matter).

这确实为我们解决了问题,并想与大家分享.

This really fixed it for us, thought to share it with you guys.

这篇关于java.sql.SQLException:[Microsoft] [ODBC驱动程序管理器]无效的描述符索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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