cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

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.

 

 

2 REPLIES 2

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> )

 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now