2016-12-01 57 views
-1

即时尝试连接到mysql数据库并操纵其中的数据,但是当我尝试运行我的代码时,它得到错误,驱动程序[java应用程序] C:\ program files \ java \ jre 1.8 .0_111 \ bin \ javaw.exe从什么我一直在阅读它,因为它启动javaw而不是java.exe,但我似乎无法弄清楚如何切换到该任何人都可以帮助我?运行eclipse时终止javaw错误

package jdbc; 

import java.sql.*; 
public class Driver { 

public static void main(String[] args) { 

    try 
    { 
     //get a connection to the database 
     Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cs160test"); 
     //create a statement 
     Statement myStmt = myConn.createStatement(); 
     //execute the sql query 
     ResultSet myRs = myStmt.executeQuery("select * from genre"); 
     //process the result set 
     while(myRs.next()) 
     { 
      System.out.println(myRs.getString("name")); 
     } 
    } 

    catch(Exception exc) 
    { 
     exc.printStackTrace(); 
    } 

} 

}

回答

0

这是没有错误。它告诉你,你的程序exited,因为没有进一步的指示要遵循。

<terminated> main [java application] path\bin\javaw.exe 

我转载此行为,发生这种情况的唯一方法是,如果你的genre表有没有记录