问题
Following are the combination of processors that I am using:-
GetFile + SplitText + ExtractText + UpdateAttribute + ExecuteSQL + ConvertAvroToJson + PutFile
Basically,I have a properties file which contains 5 comma separated values that are required by the 'DBCPConnectionPool' controller service to establish connection with the database. Here is the content of my properties file:-
jdbc:mysql://localhost:3306/test,com.mysql.jdbc.Driver,C:\Program Files\MySQL\mysql-connector.jar,root,root
Now, I am extracting the values from this properties file and storing them in manually created properties.I am using this regex to store that values into attributes using ExtractText.
ExtractedData: (.*)
Then use updateAttribute processor to manually add 5 properties and get their values from the properties file like below:
connectionURL : ${ExtractedData:getDelimitedField(1)}
driverClass : ${ExtractedData:getDelimitedField(2)}
driverLocation : ${ExtractedData:getDelimitedField(3)}
user : ${ExtractedData:getDelimitedField(4)}
password : ${ExtractedData:getDelimitedField(5)}
So, by now the attributes have got their values from the properties file and thus following values stored in them:
connectionURL : jdbc:mysql://localhost:3306/test
driverClass : com.mysql.jdbc.Driver
driverLocation : C:\Program Files\MySQL\mysql-connector.jar
user : root
password : root
Finally, Here is what I am trying to achieve. I am trying to use these above 5 attributes in the DBCPConnectionPool Controller Service like this:
Database Connection URL : ${connectionURL}
Database Driver Class : ${driverClass}
Database Driver Location(s) : ${driverLocation}
Database User : ${user}
Password : ${password}
But I am unable to establish the connection and I am getting the error 'Cannot create PoolableConnectionFactory'. It seems that the controller service is unable to read the value from the attributes. How can I pass a flowfile attribute to a controller service?
回答1:
'DBCPConnectionPool' Service Not accepting values stored in attributes
That's not an issue. This is a feature )
Connection to the database established on controller service start and not on flow file passing to the dbcp processor.
来源:https://stackoverflow.com/questions/49746815/dbcpconnectionpool-service-not-accepting-values-stored-in-attributes