Postgresql createdb is not working

Steps to reproduce:

  1. create new database on local Postgres
  2. create new project in Studio
  3. Project Properties -> Edit -> set:
    Database type = PostgreSQL
    set database name
    set username and password
  4. click Test connection to ensure everything is alright here, click Ok
  5. Entities -> New Entity - create here something, save,
  6. Run -> Update database - ensure it worked well
  7. Run -> Create database
    Expected result: database should be recreated and no error messages should be shown
    Actual result - you see error message :
    [15:50:55.295] Task ‘createDb’ failed
    java.lang.ClassNotFoundException: org.postgresql.Driver

Hi Konstantin,

We did not succeed in reproducing this problem. What versions of Platform, Studio and PostgreSQL do you use, and what was the database name?

Regards

I can not reproduce it on test project I created yesterday. It seems it might be related to multiple open/close/edit project.
But I CAN reproduce it on new just created project! I just did the same steps and see the same error.
My system:
OS X 10.11.6
Cuba Studio Server v2.2.4
platform-6-2-6
PostgreSQL 9.4.5
database name = test3, user=test3, password=test3, user is owner of this database

Oh. Error message seems to be different this time - it seems user is dropping his own database and trying to create it. And certainly he does not have such permissions. User should not be able to create databases.

[14:23:24.776] Creating database jdbc:postgresql://localhost/test3
:app-core:assembleDbScripts UP-TO-DATE
:app-core:createDb
Using database URL: jdbc:postgresql://localhost/postgres, user: test3
Executing SQL: drop database if exists test3;
Executing SQL: create database test3 with template=template0 encoding=‘UTF8’;
[ant:sql] Failed to execute: create database test3 with template=template0 encoding=‘UTF8’
:app-core:createDb FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app-core:createDb’.

org.postgresql.util.PSQLException: ERROR: permission denied to create database

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    BUILD FAILED
    Total time: 0.818 secs
    [14:23:25.633] Task ‘createDb’ failed
    org.postgresql.util.PSQLException: ERROR: permission denied to create database

If a user has no permissions, he will not be able to create databases, it’s a part of Gradle createDb logic.
Still, if you could provide us with more details on java.lang.ClassNotFoundException: org.postgresql.Driver error, that would be very helpful.

> User should not be able to create databases.
It depends. If you are working with your own local database server, its perfectly fine to have all permissions for managing databases. So the createDb task assumes that the user has such permissions and just drops and creates the database again.
If it’s not suitable for you - just use the updateDb task. If the database is empty, it will run all init scripts the same as createDb does.
See also [url=https://doc.cuba-platform.com/manual-6.2/db_update_gradle.html]https://doc.cuba-platform.com/manual-6.2/db_update_gradle.html[/url]