Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

Cause: The error occurred since hibernate is not able to connect to the database.Solution:1. Please ensure that you have a database present at the server referred to in the configuration file eg. “hibernatedb” in this case.2. Please see if the username and password for connecting to the db are correct.3. Check if relevant jars required for … Read more

Getting error: Peer authentication failed for user “postgres”, when trying to get pgsql working with rails

The problem is still your pg_hba.conf file*. This line: Should be: * The location of this file isn’t very consistent. The command locate pg_hba.conf should help; here’s some examples: /etc/postgresql/*/main/pg_hba.conf and /var/lib/pgsql/data/pg_hba.conf. After altering this file, don’t forget to restart your PostgreSQL server. If you’re on Linux, that would be sudo service postgresql restart. These are brief descriptions of both options according to … Read more

How to restart Postgresql

Try this as root (maybe you can use sudo or su): Without any argument the script also gives you a hint on how to restart a specific version Similarly, in case you have it, you can also use the service tool: Please, pay attention to the optional [version …] trailing argument. That’s meant to allow you, the user, to act on a specific … Read more

How to UPSERT (MERGE, INSERT … ON DUPLICATE UPDATE) in PostgreSQL?

9.5 and newer: PostgreSQL 9.5 and newer support INSERT … ON CONFLICT (key) DO UPDATE (and ON CONFLICT (key) DO NOTHING), i.e. upsert. Comparison with ON DUPLICATE KEY UPDATE. Quick explanation. For usage see the manual – specifically the conflict_action clause in the syntax diagram, and the explanatory text. Unlike the solutions for 9.4 and older that are given below, this feature works with … Read more

Psql could not connect to server: No such file or directory, 5432 error?

I’ve had this same issue, related to the configuration of my pg_hba.conf file (located in /etc/postgresql/9.6/main). Please note that 9.6 is the postgresql version I am using. The error itself is related to a misconfiguration of postgresql, which causes the server to crash before it starts. I would suggest following these instructions: Certify that postgresql service … Read more