加上:sultSet rs=stmt.executeQuery(rs);
或改成这样:try{
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
Connection con= null;
ResultSet rs = null;
Class.forName(sDBDriver);
con=DriverManager.getConnection("jdbc:odbc:no","","");
Statement stmt=con.createStatement();
String sql="select * from jsp
ResultSet rs=st.executeQuery(sql);
while (rs.next())
out.println(rs.gettString("name"));
stmt.close();
con.close();
rs.close();
}
catch( SQLException exception ){ throw exception;}
%>
或改成这样:try{
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
Connection con= null;
ResultSet rs = null;
Class.forName(sDBDriver);
con=DriverManager.getConnection("jdbc:odbc:no","","");
Statement stmt=con.createStatement();
String sql="select * from jsp
ResultSet rs=st.executeQuery(sql);
while (rs.next())
out.println(rs.gettString("name"));
stmt.close();
con.close();
rs.close();
}
catch( SQLException exception ){ throw exception;}
%>
String sConnStr = "jdbc:odbc:next4";
try{
Class.forName(sDBDriver);
Connection con=DriverManager.getConnection(sConnStr,"test_newnextowner","next4");
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select * from checkoff");
while (rs.next())
System.out.println(rs.getString("checkoffid"));
s.close();
}catch(Exception e){e.printStackTrace();}
这是我调试的结果完全没有问题如果还有问题说明你的odbc有问题
out.println(rs.getString("checkoffid"));
如果抛出例外说明你的odbc错误, 你还可以在第一个catch前加上
catch( SQLException exception ){ throw exception;}
测试sql的例外.