代码:
String host = System.getenv("MYSQL_HOST_MYRDB");
String port = System.getenv("MYSQL_PORT_MYRDB");
String user = System.getenv("MYSQL_ADMIN_USER_MYRDB");
String password = System.getenv("MYSQL_ADMIN_PASSWORD_MYRDB");
Connection connection;
Statement statement;
{
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/test?" +
"user=" + user + "&password=" + password);
statement = connection.createStatement();
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
报错:code: 1, error: java.sql.SQLSyntaxErrorException: Unknown database 'test'