Reputation: 85
When I want to connect to mysql database the ip seems to change. What is the problem?
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://192.168.0.135:3306/kinderopvang";
String userName = "wim";
String password = "wim";
Connection conn=DriverManager.getConnection(url,userName,password);
This is the error:
java.sql.SQLException: Access denied for user 'wim'@'192.168.0.205' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4686)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1304)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2483)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2516)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2301)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at controller.db.GebruikerDatabankSQL.testGebruikerDatabankSQL(GebruikerDatabankSQL.java:31)
at run.NewMain.main(NewMain.java:341)
As you can see I want to connect to ip address 192.168.0.135 but i connect to 192.168.0.205 which is my own ip address
Upvotes: 0
Views: 822
Reputation: 13854
you need to give the permission for remote access
grant permission first using this way
GRANT ALL ON kinderopvang.* to 'wim'@'192.168.0.135' IDENTIFIED BY 'wim';
FLUSH PRIVILEGES;
Upvotes: 2
Reputation: 12993
@javaBeginner gave you the solution, but I am posting this answer to your question.
I want to connect to ip adres 192.168.0.135 but i connect to 192.168.0.205 which is my own ip adress
The error
Access denied for user 'wim'@'192.168.0.205' (using password: YES)
It means that your machine (IP 192.168.0.205
) has not enough privilege to access the database kinderopvang
of machine (IP 192.168.0.135
).
This happens because of one of the following reasons.
Upvotes: 0
Reputation: 2887
It says the user wim@yourIP doesn't have access to the otherIP, Therefore you have to give permission for remote access.
Upvotes: 0