困扰了我一天的问题
String url = "jdbc:odbc:test";
//加载jdbc-odbc bridge 驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url, "sa", "sa");
PreparedStatement stmt =
con.prepareStatement("select * from sysobjects order by id");
ResultSet rs = stmt.executeQuery();
while (rs.next())
{
System.out.println(rs.getString("name"));
String s = (String)rs.getString("name");
System.out.println(s);
m_res.addElement((Object)s);
System.out.println(rs.getObject(1));
}
jdbc里有这样一个要求:
1 要按照表中字段顺序读
2 不能重复读一个字段这两点是初学者经常错的地方
虽然是解决了,但是花了近一天的时间,还是很郁闷。