Does anyone have experience connecting a postgres ...
# lucee
j
Does anyone have experience connecting a postgres db to lucee running on heroku? All I can access is the connection string as an environment var, but when I try to add the db and run a query I just get
java.lang.NullPointerException
.
Application.cfc
Copy code
this.datasources["test"] = {
        class: 'org.postgresql.Driver',
        bundleName: 'org.postgresql.jdbc42',
        bundleVersion: '9.4.1212',
        connectionString: 'jdbc:' & connectionString
    };
Lucee 5.3.8.206
z
As a crime scene investigator, the top of the stack trace would be really helpful, plus any caused by at the bottom
šŸ‘ 1
b
Yep, just the exception class name tells us norhing.
j
b
@jumpmaster Sorry So the line the NPE is coming from appears to be
Copy code
stat = dc.getConnection().createStatement();
so there's two things that could have been null there • the
dc
variable • the return from the
getConnection()
method
I would assume the issue itself is in the driver. Did you recently update to a newer version of the driver, or has this never worked for you?
j
@bdw429s It has never worked for me
b
Oh, interesting. Well, I've used Postgres in Lucee so I know it works in general
I can't imagine running in Heroku would make much of a difference
Are you just running a normal CFQuery with a select?
That error is happening before the query is even sent to the DB, so I'd think perhaps it's related to the actual connection information.
I've seen NPEs before when the connection string was invalid was empty, so I'd check that maybe and see if it's all in the correct place
I don't know if it's related but it's another place I've seen an NPE come from an invalid connection string
j
Running postgres locally hasn't been a problem, just connecting to the db on heroku is causing hickups. All queries have been normal cfquery Selects and queryExecute. I doubt the query was the issue, to test the connection I have even just been doing
SELECT 1 + 1;
b
What is the contents of the
connectionString
variable?
If it's coming from an env var, it could be empty!
its an env var, heroku uses DATABASE_URL by default. Made sure it is not empty
I have also tried parsing the username and password from the string and including them separately, but that did not work
@bdw429s I think I found the issue. Heroku postgres requires an ssl certificate which my localhost did not have, and I had not yet added to the heroku project.
šŸ‘ 1
b
@jumpmaster Wow, interesting. So the managed MySQL instances on Heroku explicitly disallow a user/pass authentication?
j
@bdw429s I'm not sure about mysql, but I think that's the case for the heroku specific postgres plugin. Most of this is above my head at the moment, but I'm working on it
b
oh sorry, I meant to say Postgres. I cross this thread with another thread about MySQL