Why do you think this function gives me always null?? Using another login program, which has the same code structure, it works greatly. My DBURL is jdbc:mysql://localhost:88
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
As you have mentioned problem is with creating connection with the database itself. Statement
con = DriverManager.getConnection(DatabaseURL, userName, password);
is throwing exception which is getting caught at
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
after which you are returning dbresult which you have initialized to null(which you have to as it is a local variable). So the problem is that you are unable to connect to your db due to authentication.
On your machine where (localhost in ur case ) run the following command from console
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'root' WITH GRANT OPTION;