Introduction
I'm developing a java program that can change the database connection, I have 1 local bank (127.0.0.1:3306) and a remote bank (192.168.25.75:3306) that would be a my computer, I made the connection using jdbc.
connDb.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author ralfting
*/
public class ConnDb {
public static Connection getConnection() throws SQLException{
String conexao = "jdbc:mysql://192.168.25.75:3306/teste";
String usuario = "root";
String senha = "root";
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver);
java.sql.Connection conn = DriverManager.getConnection(conexao, usuario, senha);
System.out.println("Conexão - OK");
return (Connection) conn;
}
}
JDBC Driver
Problem
WhenIusethelocalbankitworksfine,butsinceIstartusingtheremotebankitdoesnotworkitreturnsmeaSQLException
null,messagefromserver:"Host 'Ralfting.home' is not allowed to connect to this MySQL server"