org.postgresql.util.PSQLException: ERROR: database "foo" is being accessed by other users Detail: There is 1 other session using the database.

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,
via stackoverflow.com by Unknown author

Upgrade the database driver to the latest and check.

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.3-1101-jdbc41</version>
</dependency>

Replace version with the latest driver version.

,
Expert tip

Try downgrading PostgresSQL server to 9.5 or update your PostgresSQL driver to 9.4-1211 with the following command: <postgresql.version>9.4.1211</postgresql.version>

Solutions on the web

via Stack Overflow by Do Nhu Vy
, 1 year ago
ERROR: database "foo" is being accessed by other users Detail: There is 1 other session using the database.
via Stack Overflow by user1854959
, 1 year ago
ERROR: syntax error at or near "$" Position: 5
via GitHub by seanmmills
, 1 year ago
ERROR: syntax error at or near "$1" Position: 45
via GitHub by davecramer
, 1 year ago
ERROR: syntax error at or near "$1" Position: 45
via GitHub by jendib
, 4 months ago
ERROR: syntax error at end of input Position: 45
via Stack Overflow by Neelam
, 9 months ago
ERROR: could not load library "C:/Softwares/PostgreSQL/9.3/lib/pljava.dll": The specified module could not be found.
org.postgresql.util.PSQLException: ERROR: database "foo" is being accessed by other users Detail: There is 1 other session using the database.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2453)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2153)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:286)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:432)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:305)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:291)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:269)
at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:249)
at com.nttdata.RunSqlScript.dropDatabase(RunSqlScript.java:71)
at com.nttdata.RunSqlScript.main(RunSqlScript.java:28)

Users with the same issue

37 times, 1 week ago
3 times, 1 month ago
Once, 2 months ago
Once, 2 months ago
32 times, 2 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.