From: | Dave Cramer <davecramer(at)postgres(dot)rocks> |
---|---|
To: | Amn Ojee Uw <amnojeeuw(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: JDBC + PG-15 but not psql |
Date: | 2023-08-21 18:51:06 |
Message-ID: | CADK3HHLVsMqkp7sVD5+U-z2tx72QLPv8KBRhW3XRBgozYymQwg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Amn,
Can you help me understand this issue better?
I don't see anywhere in the code where you are attempting to create a
tablespace ?
Dave Cramer
On Sun, 20 Aug 2023 at 11:17, Amn Ojee Uw <amnojeeuw(at)gmail(dot)com> wrote:
> 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.
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2023-08-21 18:57:28 | Re: The same prepared query yield "-1" the first six times and then "-1.0" |
Previous Message | Edoardo Panfili | 2023-08-21 18:21:52 | Re: The same prepared query yield "-1" the first six times and then "-1.0" |