Filling a STRUCT field with a PreparedStatement in JDBC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2025 07:44 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2025 08:03 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2025 08:17 AM
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> )