Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public interface Patterns {

//Matches to part of string - hostname:port/databasename
Pattern DB_INSTANCE_MATCHING_PATTERN = Pattern.compile(
"(?<databaseHost>[^:]+)?" +
"(?<databaseHost>[^:/]+)?" +
"(:(?<databasePort>[0-9]+))?" +
"(" +
"(?<sidOrServiceName>[:/])" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,19 @@ void shouldRespectBothUrlPropertiesAndParameterProperties() throws SQLException
}
}
}

@Test
void shouldSupportUrlWithoutHostname() throws SQLException {
ContainerDatabaseDriver driver = new ContainerDatabaseDriver();
String url = "jdbc:tc:mysql:8.0.36:///databasename";

try (Connection connection = driver.connect(url, new Properties())) {
try (Statement statement = connection.createStatement()) {
try (ResultSet resultSet = statement.executeQuery("SELECT DATABASE()")) {
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getString(1)).isEqualTo("databasename");
}
}
}
}
}