localはリモートコントロールのdatabase(mysql)に接続されています。


遠端に接続されているmysql databaseですので、このパソコンのポータブルはファイアウォールを設置してください。
さもなければ邪魔されます。

import java.sql.*; 
 
public class DBConnectionDemo { 
    public static void main(String[] args) { 
        String driver = "com.mysql.jdbc.Driver"; 
        String url = "jdbc:mysql://host:3306/tablename"; 
        String user = "xxx"; 
        String password = "xxx"; 
        try { 
            Class.forName(driver); 
            Connection conn = 
               DriverManager.getConnection(url, 
                                  user, password);
 
            if(conn != null && !conn.isClosed()) {
                System.out.println("         !"); 
                conn.close();
            }
            
        } 
        catch(ClassNotFoundException e) { 
            System.out.println("         "); 
            e.printStackTrace(); 
        } 
        catch(SQLException e) { 
            e.printStackTrace(); 
        } 
    } 
}