cloudbeaver icon indicating copy to clipboard operation
cloudbeaver copied to clipboard

How to change default h2 database to postgresql?

Open miltonchirinos44 opened this issue 2 years ago • 7 comments

Hello friends, a question: How can I change the default database h2 Database Engine to postgresql database in cloudbeaver

miltonchirinos44 avatar Sep 13 '22 15:09 miltonchirinos44

The way to change the database is described in this article.

kseniaguzeeva avatar Sep 14 '22 13:09 kseniaguzeeva

I'm sorry, the link was wrong. Here is the correct one https://github.com/dbeaver/cloudbeaver/wiki/Server-configuration#database-configuration.

kseniaguzeeva avatar Sep 15 '22 12:09 kseniaguzeeva

@kseniaguzeeva, Can you help me verifying the new configuration that I want to make from h2 to postgresql as indicated in the image, can you tell me if it is ok or not? verificar configuracion Is it necessary to add the username and password?

attached files NEW POSTGRESQL DATABASE CONFIGURATION.txt CURRENT H2 DATABASE CONFIGURATION.txt

miltonchirinos44 avatar Sep 15 '22 21:09 miltonchirinos44

Here you can see the config example: { "server": { "serverName": "test", "serverURL": "http://localhost:8978", "expireSessionAfterPeriod": 1800000, "database": { "driver": "postgres-jdbc", "url": "jdbc:postgresql://your_local_host/cb", "user": "user_name", "password": "user_password" } } }

The command example to run the instance is docker run --name docker_name --rm -ti -p 8978:8978 --add-host=host.docker.internal:your_local_host -v way_to_local_configuration:/opt/cloudbeaver/workspace dbeaver/cloudbeaver:cloudbeaver_version

kseniaguzeeva avatar Sep 16 '22 14:09 kseniaguzeeva

@kseniaguzeeva
thanks for the example but my idea was to modify the base from the backend side and not by a command.

Me podria indicar cual es la carpeta donde debo modificar?

How can I modify the default h2 database to postgresql through the backend?

miltonchirinos44 avatar Sep 16 '22 16:09 miltonchirinos44

@kseniiaguzeeva , I tell you that I managed to change the configuration of the default database H2 that is by default to postgresql. I do this in the build files that are in the deploy, I understand that the files that are in the deploy are generated using the command

cd cloudbeaver/deploy
./build.sh

@kseniiaguzeeva Could you please tell me in which part of the source code I have to add or modify this configuration, so that it is configured permanently, since as I make the configuration in the configuration files, the configuration will surely be restored once I execute the command ./build.sh

FILE CONFIGURATION DEPLOY cloudbeaver.conf

file path: cloudbeaver/deploy/cloudbeaver/conf/cloudbeaver.conf

{
    server: {
        serverPort: 8978,

        workspaceLocation: "workspace",
        contentRoot: "web",
        driversLocation: "drivers",

        rootURI: "/",
        serviceURI: "/api/",

        productConfiguration: "conf/product.conf",

        expireSessionAfterPeriod: 1800000,

        develMode: false,

        enableSecurityManager: false,

        database: {
            driver="postgres-jdbc",
            url: "jdbc:postgresql://localhost:5432/postgres-milton",
            user: "postgres",
            password: "postgres",

            createDatabase: true,

            initialDataConfiguration: "conf/initial-data.conf",

            pool: {
                minIdleConnections: 4,
                maxIdleConnections: 10,
                maxConnections: 100,
                validationQuery: "SELECT 1"
            }
        }

    },
    app: {
        anonymousAccessEnabled: true,
        anonymousUserRole: "user",
        supportsCustomConnections: false,

        forwardProxy: false,

        publicCredentialsSaveEnabled: true,
        adminCredentialsSaveEnabled: true,

        resourceManagerEnabled: true,

        resourceQuotas: {
            dataExportFileSizeLimit: 10000000,
            resourceManagerFileSizeLimit: 500000,
            sqlMaxRunningQueries: 100,
            sqlResultSetRowsLimit: 100000,
            sqlResultSetMemoryLimit: 2000000,
            sqlTextPreviewMaxLength: 4096,
            sqlBinaryPreviewMaxLength: 261120
        },
        enabledAuthProviders: [
            "local"
        ],

        disabledDrivers: [
            "sqlite:sqlite_jdbc",
            "h2:h2_embedded",
            "clickhouse:yandex_clickhouse"
        ]

    }

}

image

run cloudbeaver project in eclipse "RUN -> RUN CONFIGURATIONS -> CloudbeaverServer.product -> RUN " image

Console: image

automatic table creation image

image

miltonchirinos44 avatar Sep 19 '22 16:09 miltonchirinos44

@alexander-skoblikov Thanks I managed to solve the problem

miltonchirinos44 avatar Sep 26 '22 14:09 miltonchirinos44