Looking for info on abilities and usage of Array datatype in H2

38 views
Skip to first unread message

Kenneth McDonald

unread,
Aug 17, 2011, 8:01:58 PM8/17/11
to h2-da...@googlegroups.com
I haven't been very successful in finding info about what can be done with Arrays in H2 and how to use them, and would appreciate references to any documentation/examples.

Thanks,
Ken

Thomas Mueller

unread,
Aug 20, 2011, 5:30:01 AM8/20/11
to h2-database
Hi,

> I haven't been very successful in finding info about what can be done with
> Arrays in H2 and how to use them, and would appreciate references to any
> documentation/examples.

Well, what do you _want_ to do, that is, what problem do you have and
want to solve?

The documentation is at
http://h2database.com/html/datatypes.html#array_type
http://h2database.com/html/functions.html#array_get

there are also test cases and sample applications that show how to use
arrays, for example org.h2.samples.FunctionMultiReturn.

Regards,
Thomas

Kenneth McDonald

unread,
Aug 25, 2011, 7:47:34 PM8/25/11
to h2-da...@googlegroups.com
Hi Thomas, thanks for the reply. Sorry for the delay in responding, I was out of town.

I was looking for documentation on how to store and extract elements of particular types. The basic array documentation:

ARRAY Type

ARRAY

An array of values. Use a value list (1, 2) or PreparedStatement.setObject(.., new Object[] {..})to store values.

Mapped to java.lang.Object[] (arrays of any non-primitive type are also supported).

Example:

ARRAY


indicates it is possible to store elements of general types, but I hadn't been able to find guidance on getting the element back out of the array. I'll take a look at the code sample you mentioned above. 

Cheers,
Ken

Thomas Mueller

unread,
Aug 29, 2011, 2:10:36 AM8/29/11
to h2-database
Hi,

I will extend the documentation:

Use ResultSet.getObject(..) or ResultSet.getArray(..) to retrieve the values.

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages