2016-06-11 67 views
0

有人能告訴我什麼是在下面的Java代碼如何修復錯誤:未解決編制問題:語法錯誤令牌「RS」

//SelectTest.java 
import java.sql.*; 
public class SelectTest1 
{ 
    public static void main(String args[])throws Exception 
    { 
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
     Connection con = DriverManager.getConnection("jdbc:odbc:oradsn","System","123"); 
     Statement st = con.createStatement(); 
     ResultSet rs = st.executeQuery("select*from student"); 
     { 
      while(rs.next()) 
      { 
       System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "rs.getString(3)); 
      } 
      rs.close(); 
      st.close(); 
      con.close(); 
     } 
    } 
} 
+2

'rs.getString(3)'前面沒有'+',請使用一些IDE – 2016-06-11 06:48:22

回答

0

最後的編譯錯誤

"Exception in thread "main" java.lang.Error: Unresolved compilation problems: Syntax error on token "rs", delete this token The method getString(int) is undefined for the type String at SelectTest.main"

rs.getString(3)你忘了'+'

System.out.println(rs.getInt(1)+" "+rs.getString(2)+" " +rs.getString(3)); 
相關問題