顯示的應該是什么結果呢? (45分)

悟峰

Unregistered / Unconfirmed
GUEST, unregistred user!
lass SimpleExample
{
public static void main(String args[])
{
String url="jdbc:eek:dbc:test";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection=DriverManager.getConnection(url,"sa","");
String sql="select * from sysobjects";
System.out.println("Native form:"+connection.nativeSQL(sql));
Statement statement=connection.createStatement();
ResultSet rs=statement.executeQuery(sql);
connection.close();
}
catch (Exception ex)
{
System.out.println("A problem occurred during the establishment of thd connection:"+ex);
}
}
}
我得到的顯示結果是:
Native form:select * from sysobjects
為什么?
 
你只执行了语句,并没有将结果集输出显示吧。
ResultSet rs=statement.executeQuery(sql);
while(rs.next()){
System.out.println(rs.getString("字段名"));
connection.close();
才能看到结果
 
ZRWeng 说的很对呀
你没有把结果集输出呀
while(rs.next())
{
System.out.println(rs.getString("字段名"));
}
connection.close();
 
原來這樣,我還是接著往后看,
呵呵,謝謝兩位老兄,
7syw交個朋友,qq:54540657
ZRWeng兄弟我已經加了!
 
顶部