Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setStartPoint opens alot of connections to the db #117

Open
soezen opened this issue Nov 6, 2020 · 1 comment
Open

setStartPoint opens alot of connections to the db #117

soezen opened this issue Nov 6, 2020 · 1 comment

Comments

@soezen
Copy link
Contributor

soezen commented Nov 6, 2020

When I call setStartPointNow() a lot of connections are opened.
One for getting all the tables and then the code loops over all tables and opens another connection for each table to get the table name.
Is it possible to refactor this to reuse the already open connection?

  public Changes setStartPointNow() {
    if (request == null && tablesList == null) {
      try (Connection connection = getConnection()) {
        tablesList = new LinkedList<>();
        DatabaseMetaData metaData = connection.getMetaData();
        ResultSet resultSet = metaData.getTables(getCatalog(connection), getSchema(connection), null,
            new String[] { "TABLE" });
        while (resultSet.next()) {
          String tableName = resultSet.getString("TABLE_NAME");
          Table t = new Table().setLetterCases(getTableLetterCase(), getColumnLetterCase(), getPrimaryKeyLetterCase())
                               .setName(getTableLetterCase().convert(tableName));
          copyElement(this, t);
          tablesList.add(t);
        }
      } catch (SQLException e) {
        throw new AssertJDBException(e);
      }
    }
   ...

The copyElement() method within the while loop is the place where another connection is opened to get the table name from database.
I tried to overwrite this, but many of the methods in changes are private so it seems impossible to create a workaround.

@VanRoy
Copy link
Member

VanRoy commented Feb 23, 2021

Hi @soezen , indeed it's not really easy to fix it due to the conception of Table implementation :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants