1
Introducing
I am developing a program in java that can change the connection of the database, I have 1 local database (127.0.0.1:3306) and a remote database (192.168.25.75:3306) that would be a computer of mine, 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
When I use the local bank works perfectly, but once I start using the remote bank it doesn’t work it returns me a SQLException
null, message from server: "Host 'Ralfting.home' is not allowed to connect to this Mysql server"
The error message is quite clear. You are not allowed to connect to this bank. Make sure the port is open (firewall may interfere with this) and that you can connect from your machine to that bank.
– Mansueli
Some remote banks, especially those of free hosts only allow connections from pages hosted on the server itself. A possible solution for your case is to make a REST access to communicate with your local application.
– Math
I’m sorry, reading your question better, I realized that the remote bank is on another computer of yours, correct? In this case the comment of Kyllopardiun is more useful, because it can be some firewall or something. Anyway, we have no way to find out the cause of the error if you don’t give more details of your problem.
– Math