Greetings!
I get the following error while compiling my java code:
java.sql.SQLException: Access denied for user 'root '@'localhost' (using password: YES)
I have made some research and noticed that this is a common mistake. Unfortunately i didn`t found a solution yet how simply to resolve this matter. I will appreciate any help!
I use a .properties file with the information about the database.
Here is my class:
public static void CreateTable(Connection conn, String url, String driver, String dbName, String userName, String password) { try { Class.forName(driver).newInstance(); conn=DriverManager.getConnection(url+dbName, userName, password); try { Statement st=conn.createStatement(); String table = "CREATE TABLE Server(name varchar(255), IP varchar(20), OS varchar(255), RAM integer"; st.executeUpdate(table); System.out.println("Table successfully created"); } catch(SQLException e){ System.out.println("Table already exists!"); } conn.close(); } catch(Exception e){ e.printStackTrace(); } }