I have a database hosted at a remote location. I want to access that database. But I keep getting the error
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'username'@'%' to database 'db'
This is the code that i have written
Connection con = null; Class.forName("com.mysql.jdbc.Driver"); String username = "username"; String password = "password"; String server = "220.127.116.11"; //remote server address String db = "data"; String url = "jdbc:mysql://"+server+"/"+db; con = DriverManager.getConnection(url, username, password);
The username password I provide is correct as I can access the same databse using PHP and PHPmyAdmin.