Support Questions

Find answers, ask questions, and share your expertise

Nifi DBCPConnectionPool service not setting schema

avatar
New Contributor

I am running into a problem with my DBCPConnectionPool service in Nifi and am hoping that someone has some experience with this. I'm using Nifi 2.0.0-M2.

My current Database Connection URL is
jdbc:postgresql://myurl:5432/mydatabase?currentSchema=public&stringtype=unspecified


This works great with no issues. However, I want to add another schema in there so I don't have to specify the new schema in my queries throughout all my nifi flows. For example, I was hoping this would work:
jdbc:postgresql://myurl:5432/mydatabase?currentSchema=myschema,public&stringtype=unspecified

But when I do a query like "select * from mytable" with ExecuteSQL, I get an error: 

org.postgresql.util.PSQLException: ERROR: relation "mytable" does not exist 

If I change the query to "select * from myschema.mytable", it works.

Chatgpt recommended I try this, but it also didn't work:
jdbc:postgresql://myurl:5432/mydatabase?options=-c%20search_path=myschema,public&stringtype=unspecifi...

Has anyone been able to successfully specify a different schema other than just public? I would just include the schema name in all my queries (which works), but we are going to do a separate prod and dev instance and I don't want to have to change all my queries depending on whether I'm using myschema or myschema-dev.

1 REPLY 1

avatar
Contributor

Hello @ShellyIsGolden

Glad to see you in our community. Welcome!

ChatGPT was not that wrong (😆), in fact that makes sense. 
The PostgreSQL documentation refers that method as possible: 

String url = "jdbc:postgresql://localhost:5432/postgres?options=-c%20search_path=test,public,pg_catalog%20-c%20statement_timeout=90000"; 
https://jdbc.postgresql.org/documentation/use/#connection-parameters

Have you tested the JDBC connection outside of NiFi? 
Maybe with psql command like this: 

psql -d postgresql://myurl:5432/mydatabase?options=-c%20search_path=myschema,public&stringtype=unspecified

Also, check with your PG team to see if that connect string is possible and test more on that side. 


Regards,
Andrés Fallas
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs-up button.