1

I'm trying to use a hibernate JPA from my custom Nifi processor written in Java. From inside the processor i don't have any information about connection string, username, password etc (because in the Nifi it is defined in a separated service). But i have a ready java.sql.Connection object.

DBCPService dbcpService = context.getProperty(DB_CONNECTION_POOL).asControllerService(DBCPService.class);
Connection con = dbcpService.getConnection();

Now i would need somehow to get an EntityManager (or DataSource) using only the Connection object without having db parameters. Is it possible? Will appreciate help.

yuriscom
  • 550
  • 3
  • 17
  • 1
    Asking for user1399759: "I know this is a pretty old question, but it's one of the few results that pops up on a Google search - did you happen to make headway on this issue? I'm looking at doing some complex object interaction with PostgreSQL through NiFi and would love to save some learning pains." – Antares May 05 '20 at 16:44

1 Answers1

2

Check out the comment on this (closed but not incorporated) pull request, it implies you could create your own BasicDataSource impl but delegate to the DBCPService.getConnection() call.

mattyb
  • 11,693
  • 15
  • 20