Filling a STRUCT field with a PreparedStatement in JDBC

EricCournarie
New Contributor III

Hello, 

I'm trying to fill a STRUCT field with a PreparedStatement in Java by giving a JSON string in the PreparedStatement.

But it complains 

Cannot resolve "infos" due to data type mismatch: cannot cast "STRING" to "STRUCT<AGE: BIGINT, NAME: STRING>".

it works with ARRAY, but not with STRUCT 

Did I miss something, or should it be done in another way ?

Thanks in advance.

 

 

szymon_dybczak
Esteemed Contributor III

Could you provide a sample of JSON string along with a code you're using? Otherwise it will be hard for us to help you.

Of course . The JSON looks like

{
"age" : 18,
"name" : "Erquy"
}

and I'm using the setString method of a java.sql.PreparedStatement

( for a table defined with STRUCT<age: INT, name: STRING> )