class AutomaticConnection implements Connection {

    @Override
    public PreparedStatement prepareStatement(String sql) throws SQLException {
        QueryTables tables = SqlUtil.parseTableName(sql);
        if (tables.isDml()) {
            throw new RuntimeException("Unsupported DML in JDBC model");
        }

        List<String> names = tables.tableNames;
        if (names.isEmpty()) {
            return simpleConnection.prepareStatement(sql);
        }

        //caution: tableName has changed to dbName.tableName
        if (names.stream().anyMatch(name -> !tableNames.contains(name))) {
            tableNames.clear();
            tableNames.addAll(names);
        } else {
            if (connection != null) {
                return connection.prepareStatement(sql);
            }
        }

        if (schemaPath.isEmpty()) {
            this.connection = JdbcPipeline.createSpecificConnection(
                MetadataPostman.getAssembledSchema(new ArrayList<>(tableNames)));
        } else {
            this.connection =
                JdbcPipeline.createSpecificConnection(schemaPath, new ArrayList<>(tableNames));
        }

        return connection.prepareStatement(sql);
    }

    public  AutomaticConnection(String path);
    public  AutomaticConnection();

}