Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qXizK-006y9d-Kx for pgsql-general@arkaria.postgresql.org; Sun, 20 Aug 2023 14:01:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qXizI-005Iri-9h for pgsql-general@arkaria.postgresql.org; Sun, 20 Aug 2023 14:01:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qXizH-005IrZ-Ub for pgsql-general@lists.postgresql.org; Sun, 20 Aug 2023 14:01:04 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qXizA-001EtV-Ua for pgsql-general@lists.postgresql.org; Sun, 20 Aug 2023 14:01:03 +0000 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-76da7f86d46so3424185a.2 for ; Sun, 20 Aug 2023 07:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692540054; x=1693144854; h=subject:to:content-language:user-agent:mime-version:date:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=LpQAbqKDY3pJH3uw7tXGjUKUS+01MtluGwSwiSauh+Q=; b=jBTyrJ+xNrTd86HWjQFL47goqnOpgO32rt2AhfdrhvkCawVGfNuvf9N2vfMRlZuc3p SR0wTalQdUKmrmOTsGrdjXzLU8MG84jZU3EGwxpF7tA8li7uw3wxhCskzMe/c0ZU8i+d P5W6cecgHFOvCrgKS1WIs11/9TTtFoedqKmTxYSYIzrUo06xkg8+YWUeZigsRI5e1005 AUZv32gUkBN/stAb77Ejm0+jNxQJSb3aiH/p+yxuV+BsZzSmzQY6g6QSCv/5jbgc7vpb Q+WxxX243sFWJmupjwj70CBXRENesxtnnQSV23b6OO57FiUB/4vO08wmR0FygX5D7ggj PKsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692540054; x=1693144854; h=subject:to:content-language:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LpQAbqKDY3pJH3uw7tXGjUKUS+01MtluGwSwiSauh+Q=; b=LCiZSuOGJqmumcOMvDv6PKOS7NjzRdq5+TSuj27cN+wW6nczbxYeFG+RfAifkxQvsT Qnh7Qg+Wt2ugT1UBfxqPRmL90vurxFNba82dIj0V4QHrosTvitwD1I+xSRYjrfwzfqJm gmcQl3sV7RRaOpRtHgnfhtzKdQF+8uDDv1DFWBSXb0vcIn8d0Cu+l6OoUsnVsZlR/NxH p1/fddkTbZQax+cLirSCGOaSgRA5IwTagN8PY1DJY3tXoNHSnzYxUzueisy3f9BThIuH dHr3KcsR4txhJSLqCVRo2ms3xB/utnVEvqvvl1e+kE9QkXx1Oz6b45pkrj6Wm8GitJSA Y+gg== X-Gm-Message-State: AOJu0YyxrhPDbuXwJVGtUKv6G7WtiyPNbZM7Zj7hFtk4zUGndH1Ezelj Ci732d4R5BCdW+DTxqDytuc+sKZ8TCY= X-Google-Smtp-Source: AGHT+IHp8zGtRFZqQNC7bOPhaaORf+9IjD3YzG393FnteVJgPnEZKZ61fLd0Q0exMt6tF0ooe+Xd7g== X-Received: by 2002:a05:620a:25d1:b0:768:1e00:76c4 with SMTP id y17-20020a05620a25d100b007681e0076c4mr5880265qko.51.1692540053691; Sun, 20 Aug 2023 07:00:53 -0700 (PDT) Received: from [192.168.2.170] ([67.70.150.114]) by smtp.gmail.com with ESMTPSA id v22-20020ae9e316000000b00765a676b75csm1834677qkf.21.2023.08.20.07.00.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 20 Aug 2023 07:00:53 -0700 (PDT) From: Amn Ojee Uw X-Google-Original-From: Amn Ojee Uw Content-Type: multipart/alternative; boundary="------------dxwIfHpFLhvCRTTp8F9FlwOo" Message-ID: Date: Sun, 20 Aug 2023 10:00:41 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-CA, es-ES To: pgsql-general@lists.postgresql.org Subject: JDBC + PG-15 but not psql List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------dxwIfHpFLhvCRTTp8F9FlwOo Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello. I have searched the net in an attempt to find if others have had and resolved this challenge, but most of the sites talk about how, when using the psql, this error arises. In my case, the error arises only when access PG-15 using JDBC. JDBC connects to the database, but when trying to execute a schema, it be to create a database or to create a tabelspace I get this error : *StackTrace : [Ljava.lang.StackTraceElement;@7a69b07** **Message : ERROR: CREATE TABLESPACE cannot run inside a transaction block* I have used the same algorithm, but now modify to accommodate PG-15, when using SQLite. So the JDBC code might not be the problem, but the requirements needed from PG-15. Change of perspective, I resolved the concern! Here is what changed the outcome : --- snip --- public void connectToDatabase() throws ClassNotFoundException, SQLException {     try {         Class.forName(this.getDatabaseClass().toString());         this.conn = DriverManager.getConnection(this.getDatabaseUrl().toString(),                 this.getUserID().toString(),                 this.getUserPassword().toString()); *this.conn.setAutoCommit(true);*/*//*//*game changer!!*/         this.pout("Connected to the PostgreSQL server, success!!!");         this.stmt = this.conn.createStatement();     } catch (final SQLException | ClassNotFoundException e) {         throw e;     } } -- All I had to do was to setAutoCommit to true, PG-15 set this value to false by default. I hope my experience can help others. --------------dxwIfHpFLhvCRTTp8F9FlwOo Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hello.

I have searched the net in an attempt to find if others have had and resolved this challenge, but most of the sites talk about how, when using the psql, this error arises. In my case, the error arises only when access PG-15 using JDBC.
JDBC connects to the database, but when trying to execute a schema, it be to create a database or to create a tabelspace I get this error :

StackTrace : [Ljava.lang.StackTraceElement;@7a69b07
Message : ERROR: CREATE TABLESPACE cannot run inside a transaction block

I have used the same algorithm, but now modify to accommodate PG-15, when using SQLite. So the JDBC code might not be the problem, but the requirements needed from PG-15.

Change of perspective, I resolved the concern!

Here is what changed the outcome :
--- snip ---

public void connectToDatabase() throws ClassNotFoundException, SQLException {
    try {
        Class.forName(this.getDatabaseClass().toString());
        this.conn = DriverManager.getConnection(this.getDatabaseUrl().toString(),
                this.getUserID().toString(),
                this.getUserPassword().toString());
        
        this.conn.setAutoCommit(true); // game changer!!
       

        this.pout("Connected to the PostgreSQL server, success!!!");

        this.stmt = this.conn.createStatement();
    } catch (final SQLException | ClassNotFoundException e) {
        throw e;
    }
}

--

All I had to do was to setAutoCommit to true, PG-15 set this value to false by default.


I hope my experience can help others.


--------------dxwIfHpFLhvCRTTp8F9FlwOo--