Support Questions
Find answers, ask questions, and share your expertise

Is is possible to use flowfile attribute expressions in the Database Connection URL property for a DBCPConnectionPool controller service?

New Contributor

When I try and use a jdbc connection string from a flowfile attribute in the DBCPConnectionPool I get the following error:

2017-01-27 17:52:20,366 ERROR [Timer-Driven Process Thread-9] o.a.n.p.standard.ConvertJSONToSQL org.apache.nifi.processor.exception.ProcessException: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL ''

I have it configured in the following way:

11826-nifi1.png

11827-nifi2.png

Thanks for your assistance.

1 REPLY 1

Re: Is is possible to use flowfile attribute expressions in the Database Connection URL property for a DBCPConnectionPool controller service?

Super Guru

It is not currently possible to use flowfile attributes for the Database Connection URL, as the service is initialized before the flow can use it. However that property does support Expression Language, so you could use the Variable Registry to parameterize that field. To do so using the file-based Variable Registry (the only option at the time of this writing), create a file somewhere called "var_registry.properties" or something, and add the line:

connectionstring2=jdbc:sqlserver://<your_url_here>

Then in conf/nifi.properties, set the "nifi.variable.registry.properties" property to the location of your file:

nifi.variable.registry.properties=var_registry.properties

Restart NiFi, and you should see the DBCPConnectionPool using your URL in place of ${connectionstring2}. This feature can be used to migrate from test to production environments, where your flows can be the same, but the URL can be changed by having a different value in the production's variable registry than the one in the test environment.