我试图连接到mysql数据库并操纵其中的数据但是当我尝试运行我的代码时它得到错误,驱动程序[java application] C:\ program files \ java \ jre 1.8.0_111 \ bin \ javaw .exe从我一直在阅读它因为它启动javaw而不是java.exe但我似乎无法弄清楚如何切换到那可以任何人帮助我吗?
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 :(得分:0)
这不是错误。它告诉您您的计划exited
,因为没有进一步的说明。
<terminated> main [java application] path\bin\javaw.exe
我重现了这种行为,这种情况发生的唯一方法就是你的genre
表格没有记录。
答案 1 :(得分:0)
确保已保存所有类,包括具有main方法的一类。如果那不起作用,请关闭Eclipse并重新打开它。