terminated javaw error when running eclipse

2.4k Views Asked by At

im trying to connect to mysql database and manipulate the data in it but when i try to run my code it get the error, driver [java application] C:\program files\java\jre 1.8.0_111\bin\javaw.exe from what ive been reading its because its launching javaw and not java.exe but i cant seem to figure out how to switch to that can anyone help me?

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();
    }

}

}

2

There are 2 best solutions below

0
rodridevops On

That is no error. It is telling you that your program exited because there wasn't further instructions to follow.

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

I reproduced this behavior and the only way this is happening is if your genre table has no records.

0
Farai Mugaviri On

Ensure that all your classes are saved, including the one with the main method. If that does not work, close Eclipse and reopen it.