Configuring PostgreSQL on Play! 2.6 - postgresql

I have a PostgreSQL(v9.6) instance running on my machine. The database is called 'postgres'. I've managed to open the application in pgAdmin 3 using localhost:5432. In my Play! application(v2.6.2) I have added the driver and the url to the application.conf file following the tutorial here and I have added the javaJdbc dependency to my build.sbt file. So I have the following:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/postgres"
db.default.username = "user"
db.default.password = "pass"
When I run the application though I get this error in the console:
Cannot connect to database [default]
Could somebody explain to me why this is the case? I can provide more information if I need to.

So after quite a bit of digging, it turns out the problem was actually me missing the postgres dependency. If anyone encounters this problem I would suggest checking your build.sbt file and adding the org.postgres dependency if you are missing it.
This documentation on the play website doesn't explain this step.

Related

Got com.google.inject.ProvisionExceptionerror when using PostgreSQL JDBC on GraphDB - dependency issue?

I'm getting a provision error when using PostgreSQL JDBC on GraphDB. Actually, I created a connection between postgresql and Graphdb by a virtual repository, and I made a ODBC file which includes the RDF mapping information.
Expected: Normaly I can browse PostgreSQL data's hierarchy and so on in GraphDB.
Error: The connection was fine and the repository was created successfully, but when I tried to browse the data, I got this error:
Actions that I did: I did go /opt/graphdb-free/app/lib/plugins/dependencies-plugin/dependencies-plugin.jar to modify the dependency parameter, but it didn't change anything. I did checked the syntax of ODBC file and I don't see anything wrong there.
Anyone have been though this? Was I in the right place to modify the dependency? Or it's something else?

Add Liquibase extension to Keycloak

I am trying to use the Keycloak docker image with a non-standard database (HANA-DB).
Modifying the configuration as described in the documentation worked fine and keycloak connects to the database. The remaining problem seems to be that the Liquibase migrations can not run because Liquibase does not know how to handle HANA-DB out of the box.
Of course, there is an extension library (https://mvnrepository.com/artifact/org.liquibase.ext/liquibase-hanadb/4.0.0) that adds this capability to Liquibase. Now my question: How do I get Keycloak's Liquibase to use this library?
I already tried:
Packaging the library into its own module and adding a dependency to it in Keycloak's Liquibase module
Adding the library as a second resource-root to Keycloak's Liquibase module
Both did not work, i.e. Liquibase is still not recognizing the "HDB" database.
What would be the correct way to do this?
I actually made it!
The way i achieved it is not perfekt, but keycloak 11.0.2 Docker Image is running.
Keycloak with Hana and Liquibase Migration to Hana DB is working and by now all tests for us have passed.
I'll just give you a short description what I did. And maybe write a little Blog Entry for that.
Basically you answer helped me at some point and you were on the right track.
What I did:
Creating another DB Vendor for JBoss CLI Bootstrap Scripting (https://medium.com/#victor.boaventura/keycloak-using-alternative-databases-e2b13576c457).
Hana DB Driver also needed a Global Module /subsystem=ee:write-attribute(name="global-modules",value=[{"name" => "jdk.net","slot" => "main"}, {"name" => "org.liquibase","slot" => "main"}]) (JBOSS CLI)
Keycloak did not autodiscover the correct Hibernate Dialect, so had to add that as well: /subsystem=keycloak-server/spi=connectionsJpa/provider=default/:write-attribute(name=properties,value={"dataSource" => "java:jboss/datasources/KeycloakDS","initializeEmpty" => "true","driverDialect" => "org.hibernate.dialect.HANAColumnStoreDialect","migrationStrategy" => "update","migrationExport" => expression "${jboss.home.dir}/keycloak-database-update.sql"})
Updated the Liquibase Module to Version 3.6.3 and added Liquibase Hana DB Adapter 3.9.0 (https://github.com/liquibase/liquibase-hanadb) as second resource root in same module. (Was kinda tricky to get the versions working) Also the Module needed another dependency on 'org.slf4j' to get the Logging to work.
At this Point I struggled with Liquibase Package Scanning and Keycloaks exclusion on 'liquibase.ext'. Thats why I had to add the SystemProp 'liquibase.scan.packages' (Thanks to you here :))
liquibase.scan.packages=org.keycloak.connections.jpa.updater.liquibase.lock,liquibase.change,liquibase.changelog,liquibase.database,liquibase.parser.core.xml,liquibase.precondition,liquibase.datatype,liquibase.serializer.core.xml,liquibase.sqlgenerator,liquibase.executor,liquibase.snapshot,liquibase.logging,liquibase.diff,liquibase.structure,liquibase.structurecompare,liquibase.lockservice,liquibase.sdk.database,liquibase.ext
After that Keycloak recognized Hana DB for Liquibase and the Migration started. I was super happy, but one Problem solved the next comes up...
2 of the liquibase changelogs were not working with Hana DB due to some SQL specifics. Thats why I created two patches and applied them to the keycloak-model-jpa module. Basically they already handled special cases (that failed) for oracle, so I just added 'hana' to every preCondition, where 'oracle' was mentioned and it worked!
This is basically my solution. If you have any questions please feel free to ask them here or contact me.
It turns out, that adding the library as a second resource-root in Keycloaks's liquibase module is actually working. It does not get loaded because Keycloak removes liquibase.ext from the service loader used to find liquibase extensions.
This can be worked around by using the liquibase.scan.packages system property, though.
For all those trying to make Keycloak working with HANA:
Overriding the liquibase.scan.packages system property causes the library to be loaded
Now, a class (LoggingService) from liquibase that is referenced in the liquibase-hanadb library, can not be found because it was introduced in liquibase 3.6 and Keycloak comes with 3.5.5.
When hacking a more recent version of liquibase (3.6.0) into Keycloak's modules, for some reason a changeset only intended for DB2 is being run, causing errors. I suspect an incompatibility between Keycloak's changelogs and the updated liquibase version.
I gave up at this point.

How to connect mongodb to neo4j

I am trying to connect mongodb data to neo4j.
I tried with this code "CALL apoc.mongodb.get('mongodb://localhost:27017','test','test',{name:'testDocument'})" in Neo4j.
But I get an error as
There is no procedure with the name apoc.mongodb.get registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
I had added APOC jar files in Neo4j plugins and I gone through this link http://indexoutofrange.com/Neo4jStoredProceduresWindows/
still Iam unable to connect.
can someone please explain what shall i do to get this started.
Thanks
In addition to copying the APOC jar file to $NEO4J_HOME/plugins you'll also need to copy the mongo specific jar files into $NEO4J_HOME/plugins. For example:
mvn dependency:copy-dependencies
cp target/dependency/mongodb*.jar target/dependency/bson*.jar $NEO4J_HOME/plugins/
More information available in the docs here
I know this was made 5 years ago but this is for anyone else (like myself) who's looking for an answer.
The URI should look something like this:
CALL apoc.mongo.find("mongodb://localhost:port/databaseName.collectionName")

Play Framework run test in Codeship with database

I need to run test for my Play app in Codeship. The problem is that my app cannot find the database to connect to, and this all tests are failing.
From the doc, I suppose that there are 3 different Postgres DBs (9.2, 9.3, 9.4) that I can use, so I configure my conf as below.
Please let me know where I got it wrong.
I finally found out why my test could not find the database. It was because running the test with sbt test -Dconfig.resource=test.application.conf is not a valid way to specify java option for test.
I have to go to the build.sbt file and add the following for test to load the correct config like illustrated below.

Why Playframework database configuration error in application.conf

I have have correct PostgreSQL installed and I can use this by other framework such as Spring. When I tried write some code for Play 2.1 that should use postgresql 9.4.1. I'm also using Slick 3.0.
I have following in the application.conf
db.default.driver="org.postgresql.Driver"
db.default.url="jdbc:postgresql:mydb"
db.default.user=myuser

db.default.password=mypass
When I start application it give error:-
Missing configuration [db.ansiDump.driver]
I added
db.ansiDump.driver="org.postgresql.Driver"
db.ansiDump.url="jdbc:postgresql:mydb"
Then I get error:-
Missing configuration [db.unicodeDump.driver]
I added
db.unicodeDump.driver="org.postgresql.Driver"

db.unicodeDump.url="jdbc:postgresql:mydb"
Then I get error:-
Missing configuration [db.dumpPaths.driver]
So again I added:-
db.dumpPaths.driver="org.postgresql.Driver"
db.dumpPaths.url="jdbc:postgresql:mydb"
After all these sequence of driver and url, It worked. I am sure, I am doing something wrong to configure drive o url.
Please tell me what is wrong and how it should be done.
Updated infromation:-
Additional information.
Sorry I can't keep correct format for the whole application.conf file content. So I uploaded it in Google Drive. Please check the link enter link description here
To reproduce the error I had to comment line number 45 #db.ansiDump.driver="org.postgresql.Driver"
After comment I get this exception:-
Configuration error
Missing configuration [db.ansiDump.driver]
In /Users/ma/work/app/conf/application.conf:45
I think the url should be
db.default.url="jdbc:postgresql://localhost:5432/dbName"