Hi Mark,
Thanks for your question. Unfortunately the "Database Connection URL” does not 
support reading flow file attributes.
DBConnectionPool is intended to hold and reuse connections to a single data 
source.

In its definition below, it only support reading from (Nifi variables in 1.X) 
or environment variables or NiFI parameters because it says 
ExpressionLanguageScope.ENVIRONMENT.
It needs the DB URL when the service is started and DB URL can not be changed 
while the processor is running so it can not read flow file attributes to 
change the data source URL.
My interpretation is that it is intentional and can not be changed in the code 
without breaking the DBConnectionPool service or requiring such a major rewrite 
that it would be a whole different service.

    public static final PropertyDescriptor DATABASE_URL = new 
PropertyDescriptor.Builder()
            .name("Database Connection URL")
            .description("A database connection URL used to connect to a 
database. May contain database system name, host, port, database name and some 
parameters."
                    + " The exact syntax of a database connection URL is 
specified by your DBMS.")
            .addValidator(new ConnectionUrlValidator())
            .required(true)
            .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
            .build();


I suggest you investigate the documentation on DBCPConnectionPoolLookup.
DBCPConnectionPoolLookup is implemented to allow a flow file to specify which 
database to act upon.
DBCPConnectionPoolLookup holds references to DBCPConnectionPool’s and then uses 
the flow file to select the desired data source.
That probably will do what you are looking for.


Sincerely,
Jim Steinebrey



> DBCPConnectionPoolLookupOn Jul 8, 2024, at 12:36 PM, Mark Moore 
> <[email protected]> wrote:
> 
> Hi,
>  
> We are trying to create a DBCPConnectionPool service for a dynamic connection 
> to different end pts and databases using flow attributes that are correctly 
> evaluated elsewhere but in this field these attributes do not seem to get 
> evaluated correctly.
>  
> Database Connection URL :  jdbc:postgresql://${endpt}:5432/${db} 
> <postgresql://${endpt}:5432/$%7Bdb%7D> errors out saying connection to 
> localhost:5432 is refused.
>  
> Thanks
>  
> Mark Moore
> Software Developer – BI & Analytics
> Time: GMT -6:00
> [email protected] <mailto:[email protected]>
> <image001.png>

Reply via email to