我用过:
Connection connection = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test", "username", "password"
);
Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE a (id int not null primary key, value varchar(20))");
stmt.close();
connection.close();
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误"无路由到主机"