Eclipse Luna F6不会跨越

问题描述:

奇怪的是,我在Eclipse Luna中有一个Java应用程序,当调试它时,我试图使用F6它不会“超越”,而是“步入”。Eclipse Luna F6不会跨越

+0

这个问题似乎是脱离主题,因为它缺乏任何细节使其可以回答。 – 2014-10-31 09:47:43

+0

你是否仔细检查了你的钥匙扣? – GGrec 2014-10-31 10:06:30

我正试图在Eclipse Luna中构建Java应用程序。这是一个来自 here的数据库应用程序。

随着两个源文件(DB.java):

`import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 

public class DB { 

public Connection conn = null; 

public DB() { 
    try { 
     Class.forName("com.mysql.jdbc.Driver"); 
     String url = "jdbc:mysql://localhost:3306/Crawler"; 
     conn = DriverManager.getConnection(url, "root", "admin213"); 
     System.out.println("conn built"); 
    } catch (SQLException e) { 
     e.printStackTrace(); 
    } catch (ClassNotFoundException e) { 
     e.printStackTrace(); 
    } 
} 

public ResultSet runSql(String sql) throws SQLException { 
    Statement sta = conn.createStatement(); 
    return sta.executeQuery(sql); 
} 

public boolean runSql2(String sql) throws SQLException { 
    Statement sta = conn.createStatement(); 
    return sta.execute(sql); 
} 

@Override 
protected void finalize() throws Throwable { 
    if (conn != null || !conn.isClosed()) { 
     conn.close(); 
    } 
} 
}` 

和Main.java:

`import java.io.IOException; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
import org.jsoup.Jsoup; 
import org.jsoup.nodes.Document; 
import org.jsoup.nodes.Element; 
import org.jsoup.select.Elements; 


public class Main { 
    public static DB db = new DB(); 

    public static void main(String[] args) throws SQLException, IOException { 
     db.runSql2("TRUNCATE Record;"); 
     processPage("http://www.mit.edu"); 
    } 

    public static void processPage(String URL) throws SQLException, IOException{ 
     //check if the given URL is already in database 
     String sql = "select * from Record where URL = '"+URL+"'"; 
     ResultSet rs = db.runSql(sql); 
     if(rs.next()){ 

     }else{ 
      //store the URL to database to avoid parsing again 
      sql = "INSERT INTO `Crawler`.`Record` " + "(`URL`) VALUES " + "(?);"; 
      PreparedStatement stmt = db.conn.prepareStatement(sql, 
       Statement.RETURN_GENERATED_KEYS); 
      stmt.setString(1, URL); 
      stmt.execute(); 

      //get useful information 
      Document doc = Jsoup.connect("http://www.mit.edu/").get(); 

      if(doc.text().contains("research")){ 
       System.out.println(URL); 
      } 

      //get all links and recursively call the processPage method 
      Elements questions = doc.select("a[href]"); 
      for(Element link: questions){ 
       if(link.attr("href").contains("mit.edu")) 
       processPage(link.attr("abs:href")); 
      } 
     } 
    } 
}` 

忘了包括MySQL的连接器的Java-5.1.16槽。 jar进入构建路径。 这会导致DB() 初始化程序代码中发生初始化时发生异常。至少这是我的假设,Eclipse的行为是 恼火(也许它是一个功能?),并且这一步没有正常工作。