-1

I am new bee in java and I am following a tutorial to create a database connection between my javafx application and a mysql database. However the IDE gives an error when I declare ResultSet. The error displayed is : error: cannot find symbol ResultSet = rs;

I checked this and this similar question but the problem seemed different even though the question was similar. All solutions given haven't worked.

I am running netbeans on MacOSX.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pkg3treka;

import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import java.sql.ResultSet;


/**
 * FXML Controller class
 *
 * @author User
 */
public class NewUserViewController implements Initializable {

    /**
     * Initializes the controller class.
     */
    
    public Connection getConnection(){
    Connection con;
    try{
    
        con = DriverManager.getConnection("jdbc:mysql://localhost/trekka", "root", "");
        return con;
        
    }catch(SQLException e){
    
        e.printStackTrace();
        return null;
    }
    }
    
    public ArrayList<User> userList(){
    
        ArrayList<User> usersList = new ArrayList<User>();
        Connection connection = getConnection();
        
        String query = "SELECT * FROM Users";
        Statement st;
        ResultSet = rs;
        
        try {
        
            st = connection.createStatement();
            rs = st.executeQuery(query);
            User user;
            while(rs.next()){
            
                user = new User(rs.getID("U_id"));
                usersList.add(user);
            }
            
        }catch(Exception e){
        
            e.printStackTrace();
        }
        return usersList;
    }
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
DvixExtract
  • 1,275
  • 15
  • 25

1 Answers1

2

Remove the equals sign

ResultSet = rs; 
devsaki
  • 751
  • 3
  • 10