I want to connect to a MySQL database. While installing MySQL I did not give any password, so in my program I did the same but I am getting error on connection. I am using properties file to get the driver, URL, username and password. Help me pleas.
This is my code:
catch (Exception e)
System.out.println("Got Error While Connecting To Database...!");
using password: NO - this means the program is not passing any password, in your case that is correct.
Since you mention that you are reading the values from the properties file, I don't see you doing that in the code you have posted. If you are really reading the values from the properties file in your actual code, and the MySQL server is a remote server, then make sure that you grant relevant permissions on the remote MySQL server with the below statement
grant all privileges on easylibdb1.* to 'root'@'192.168.1.51' to allow connections originating from 192.168.1.51
grant all privileges on easylibdb1.* to 'root'@'%' to allow connections originating from anywhere