I did a project using NetBeans 8 where I have to connect to a mysql dataBase and display the content in a table. While I am using the IDE the connection works just fine! But when I clean and build to create an executable jar, My program cannot connect to the dataBase... Could anyone help me with this? Thank you!
That is the code I am using:
@FXML
    private void loadDB() {
        //cleaning all fields from table View and removing previous elements from studentList before show new content;
        tableView.getItems().clear();
        studentList.removeAll();
        String stg = dataBaseField.getText();
        //Expected string format:
        //jdbc:mysql://mymysql.senecacollege.ca/eden_burton?user=jac444_183a01&password=eqXE@4464
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            System.out.println("Error loading the driver" + e);
        }
        try {
            //connecting to the database
            Connection conexao = DriverManager.getConnection(dataBaseField.getText());
            //creating a statement and query to be executed
            Statement myStmt = conexao.createStatement();
            ResultSet result = myStmt.executeQuery("select * from Students");
            //look at the result set
            while (result.next()) {
                Student student_ = new Student(result.getInt("id"), result.getString("name"), result.getString("course"), result.getInt("grade"));
                studentList.addNaLista(student_);
                tableView.setItems(getStudent(studentList.getList()));
            }
            myStmt.close();//closing statement
            result.close();//closing results
            conexao.close();//closing connection
        } //if a connection could not be set.
        catch (SQLException exc) {
            alert("CONNECTION ERROR!", "Please verify your connection string.", "String should be in the following format: " + "\n\njdbc:mysql://mymysql.senecacollege.ca/DATABASENAME?user=USERNAME&password=PASSWORD");
        }
    }
 
     
    