por favor me ajudem. Ja faz algum tempo q tento conectar um banco qualquer de um outra máquina, mas sempre dá o mesmo erro. Alguem poderia me dizer o pq disso??
logo abaixo esta um exemplo de codigo q venho utilizando, ele funciona blz localhost.
import java.sql.*;
public class TesteBanco{
private Statement st;
private Connection con;
private ResultSet result;
public TesteBanco(){
conectarSGBD();
}
public void gravarDados(String n,int i){
try{
int gravar = st.executeUpdate("INSERT INTO tabela(`idade`,`nome`) values("+i+",'"+n+"')");
if(i==0)
System.out.println("Ok");
}
catch(SQLException e){
e.printStackTrace();
}
}
public void lerDados(){
try{
result = st.executeQuery("SELECT * FROM tabela");
while(result.next()){
System.out.println(result.getString("nome"));
}
}catch(SQLException e){
e.printStackTrace();
}
}
public void conectarSGBD(){
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(
"jdbc:mysql://10.203.1.76/Teste?user=wso&password=payner"
);
st = con.createStatement();
}catch(ClassNotFoundException exception){
exception.printStackTrace();
}
catch(SQLException exception){
exception.printStackTrace();
}
}
public void close(){
try{
st.close();
con.close();
}catch(SQLException e){
e.printStackTrace();
}
}
public static void main(String args[]){
TesteBanco banco = new TesteBanco();
banco.lerDados();
}
}


