I have a mysql database running on a wamp server, I want to make a connection to mysql database using a Servlet Class in Java inorder to access the data in the database how can i do this.
private static final String url = "jdbc:mysql://192.168.1.6:3306/hospital_mangement";
private static Connection con;
static {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(url, "", "");
} catch (Exception e) {
e.printStackTrace();
}
This is the way i tried to connect to the mysql database running on the wamp server but it doesnt seem to work.
When i run this program and try to access the database in my Apache tomcat log the following error appears.
java.sql.SQLException: null, message from server: "Host 'test-PC' is not allowed to connect to this MySQL server"