Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsterChenzhuo committed Jun 16, 2023
1 parent f7eae1b commit 62337c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -99,7 +100,7 @@ private static MySqlContainer createMySqlContainer() {
mySqlContainer.withUsername(MYSQL_USER_NAME);
mySqlContainer.withPassword(MYSQL_USER_PASSWORD);
// For local test use
// mySqlContainer.setPortBindings(Collections.singletonList("3308:3306"));
mySqlContainer.setPortBindings(Collections.singletonList("3308:3306"));
return mySqlContainer;
}

Expand All @@ -115,7 +116,7 @@ public void startUp() {
log.info("The second stage:Starting Mongodb containers...");
mongodbContainer = new MongoDBContainer(NETWORK);
// For local test use
// mongodbContainer.setPortBindings(Collections.singletonList("27017:27017"));
mongodbContainer.setPortBindings(Collections.singletonList("27017:27017"));
Startables.deepStart(Stream.of(mongodbContainer)).join();
mongodbContainer.executeCommandFileInSeparateDatabase(MONGODB_DATABASE);
initConnection();
Expand Down Expand Up @@ -204,15 +205,16 @@ private List<List<Object>> querySql() {
}

private void upsertDeleteSourceTable() {
mongodbContainer.executeCommandFileInDatabase("InventoryDDL", MONGODB_DATABASE);
mongodbContainer.executeCommandFileInDatabase("inventoryDDL", MONGODB_DATABASE);
}

public void initConnection() {
String ipAddress = mongodbContainer.getHost();
Integer port = mongodbContainer.getFirstMappedPort();
String url =
String.format(
"mongodb://%s:%s@%s:%d/%s?authSource=admin",
"stuser", "stpw", ipAddress, 27017, "inventory.products");
"stuser", "stpw", ipAddress, port, MONGODB_DATABASE+"."+MONGODB_COLLECTION);
client = MongoClients.create(url);
}

Expand Down

0 comments on commit 62337c8

Please sign in to comment.