Lists: | pgsql-interfaces |
---|
From: | Charles Kong <kdy77k(at)gmail(dot)com> |
---|---|
To: | pgsql-interfaces(at)lists(dot)postgresql(dot)org |
Subject: | Use java interface "setArray" to insert the array of user-defined type to table |
Date: | 2022-02-23 14:58:04 |
Message-ID: | CA+PCg_ymO5pJ=zK+m6NGdwTNkZ5gtMQJ+_hNUuaQiwRkCPDhTA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-interfaces |
Hi all,
I use a user-defined type in “schema.sql”
CREATE TYPE infoEntity AS (
"entity_id" bigint,
"seq" integer,
"message" varchar(255)
)
in java code:
java_infoEntity[] infoEntityArray; //java_infoEntity is the class with the
same member variables.
infoEntityArray = new java_infoEntity[3];
infoEntityArray[0] = new java_infoEntity();
....
//info_Entity's type is user-defined type "infoEntity".
sql = "insert into \"T_abc\" (info_Entity) values(?);";
statement = conn.prepareStatement( sql );
Array array = conn.createArrayOf("infoEntity", infoEntityArray);
statement.setArray(1,array);
statement.addBatch();
statement.executeBatch();
....
....
Sql throw exception:
sqlException: SQLState: 22P02 Error Code: 0 Error Message: Batch entry 0
insert into "T_abc" (info_Entity)
values('{"com(dot)xxx(dot)java_infoEntity(at)597d57aa"}')
was aborted: ERROR: malformed record literal: "
com(dot)xxx(dot)java_infoEntity(at)597d57aa"
*How to cope with it?*
From: | Dave Cramer <davecramer(at)postgres(dot)rocks> |
---|---|
To: | Charles Kong <kdy77k(at)gmail(dot)com> |
Cc: | pgsql-interfaces(at)lists(dot)postgresql(dot)org |
Subject: | Re: Use java interface "setArray" to insert the array of user-defined type to table |
Date: | 2022-02-23 15:00:43 |
Message-ID: | CADK3HHK7Rs_MYCibf=Uki17-j_ixjOfbkPij4fYuoKZM3HnhRg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg배트맨 토토SQL : |
On Wed, 23 Feb 2022 at 09:58, Charles Kong <kdy77k(at)gmail(dot)com> wrote:
> Hi all,
> I use a user-defined type in “schema.sql”
> CREATE TYPE infoEntity AS (
> "entity_id" bigint,
> "seq" integer,
> "message" varchar(255)
> )
>
> in java code:
> java_infoEntity[] infoEntityArray; //java_infoEntity is the class with the
> same member variables.
> infoEntityArray = new java_infoEntity[3];
> infoEntityArray[0] = new java_infoEntity();
> ....
>
> //info_Entity's type is user-defined type "infoEntity".
> sql = "insert into \"T_abc\" (info_Entity) values(?);";
> statement = conn.prepareStatement( sql );
> Array array = conn.createArrayOf("infoEntity", infoEntityArray);
> statement.setArray(1,array);
> statement.addBatch();
> statement.executeBatch();
> ....
> ....
> Sql throw exception:
> sqlException: SQLState: 22P02 Error Code: 0 Error Message: Batch entry 0
> insert into "T_abc" (info_Entity)
> values('{"com(dot)xxx(dot)java_infoEntity(at)597d57aa"}') was aborted: ERROR:
> malformed record literal: "com(dot)xxx(dot)java_infoEntity(at)597d57aa"
>
> *How to cope with it?*
>
>
The JDBC driver does not know how to deal with user defined types. You will
have to write code to serialize the type yourself.
Regards,
Dave
From: | 陈 <bchen90(at)163(dot)com> |
---|---|
To: | "pgsql-interfaces(at)lists(dot)postgresql(dot)org" <pgsql-interfaces(at)lists(dot)postgresql(dot)org> |
Subject: | Can 32bit libpq to access 64bit postgres |
Date: | 2022-04-09 03:52:34 |
Message-ID: | 35dd878e.923b.1800c73c072.Coremail.bchen90@163.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-interfaces |
Hi, all
We use 32bit postgres V11 in our product, Now we want to add new process witch is 64bit
to access the 32bit progres using 64bit libpq.
I tried to access the PostgresDB 32bit v11, with 64 bit libpq V11, and it worked very nice.
So my question is, can we use 64bit lippq to access 32 bit postgres?
Thank you,
BoChen
From: | 陈 <bchen90(at)163(dot)com> |
---|---|
To: | "pgsql-interfaces(at)lists(dot)postgresql(dot)org" <pgsql-interfaces(at)lists(dot)postgresql(dot)org> |
Subject: | Can 64bit libpq to access 32bit postgres |
Date: | 2022-04-09 03:53:38 |
Message-ID: | 59eba721.9248.1800c74bb86.Coremail.bchen90@163.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-interfaces |
Hi, all
We use 32bit postgres V11 in our product, Now we want to add new process witch is 64bit
to access the 32bit progres using 64bit libpq.
I tried to access the PostgresDB 32bit v11, with 64 bit libpq V11, and it worked very nice.
So my question is, can we use 64bit lippq to access 32 bit postgres?
Thank you,
BoChen