Reputation: 1689
I just recently upgraded my database on Heroku from the Hobby dev
plan to the Standard 0
plan. My application was working just fine on the Hobby Dev plan with regards to inserting data. I changed the DATABASE_URL
to the new DATABASE_URL
. I am receiving the correct credentials, which I have verified by printing them out. The new rows are not being inserted into the database though. Has anyone experienced something like this before?
Let me know if there is any other data I can provide to help you
Edit more data:
override def database: DatabaseDef = {
println("CREATING DATABASE FROM URL")
val dbUri = new URI(System.getenv("DATABASE_URL"))
val username = dbUri.getUserInfo.split(":")(0)
println("Username: " + username)
val password = dbUri.getUserInfo.split(":")(1)
println("password " + password)
val dbUrl = "jdbc:postgresql://" + dbUri.getHost + dbUri.getPath
println("url " + dbUrl)
JdbcBackend.Database.forURL(dbUrl, username, password, null, "org.postgresql.Driver")
}
}
That is the method that I am trying to use to connect to my data source, which works when I am on the Hobby Dev
postgres plan. The only difference that I can see is that Hobby Dev
is postgres 9.3.5
while the Standard 0
plan is 9.3.6
EDIT 2:
I am using the play-slick dependency and this postgres dependency:
"com.typesafe.play" %% "play-slick" % "0.8.1",
"org.postgresql" % "postgresql" % "9.4-1200-jdbc41" withSources() withJavadoc()
Upvotes: 0
Views: 256
Reputation: 10338
Will is correct. This is what it should look like:
def getConnection(): Connection = {
val dbUri = new URI(System.getenv("DATABASE_URL"))
val username = dbUri.getUserInfo.split(":")(0)
val password = dbUri.getUserInfo.split(":")(1)
val dbUrl = s"jdbc:postgresql://${dbUri.getHost}:${dbUri.getPort}${dbUri.getPath}"
DriverManager.getConnection(dbUrl, username, password)
}
Upvotes: 0
Reputation: 2961
Your connection setup does not include setting the port, and it is very likely that on your s0 plan, it's not 5432.
Parse out the port from the DATABASE_URL and pass that into jdbc however that's done.
Upvotes: 3