我在编写一个关于JDBC的程序,而程序在运行时出现了下面的错误,小弟实在解决不了,想请教各位大师们. java.sql.SQLException: Column not found at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:185 2) at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
at QueryoDBCTest.getStudent(QueryoDBCTest.java:25) at QueryoDBCTest.main(QueryoDBCTest.java:15) 这个错误是不是说找不到SQLException? 下面是原程序:其中我在数据库中添加了一个1111.mdb的表: import java.sql.SQLException; import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.DriverManager; import java.sql.Date; public class QueryoDBCTest { private Connection con; public static void main(String [] args) { QueryoDBCTest test = new QueryoDBCTest(); Connection con = test.getConnection(); String sql = "select * from 1111"; test.getStudent(con,sql); } public void getStudent(Connection con,String sql) { try { Statement st = con.createStatement(); ResultSet rs = st.executeQuery(sql); while(rs.next()) { String name = rs.getString("姓名"); String Number = rs.getString("学号"); Date Date = rs.getDate("出生日期"); String spe = rs.getString("专业"); String address = rs.getString("籍贯"); System.out.println("姓名" + name + "学号" + Number + "出生日期" + Date + "专业" + spe + "籍贯" + address); } st.close(); con.close(); } catch(SQLException e) { e.printStackTrace(); } } public Connection getConnection() { String URL = "jdbc:odbc:111"; String userName = ""; String password = ""; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection(URL,userName,password); } catch(SQLException e) { e.printStackTrace(); } catch(ClassNotFoundException ex ) { ex.printStackTrace(); } return con; } }