Hi everybody,
I saw there is ARRAY data type, so I try to use it. But I have 2 problems.
I created a table at first: create table userdata(userid int, friends ARRAY)
1) Then, I want to insert to records:
String query = "insert into userdata values(?, ?)";
PreparedStatement prep = conn.prepareStatement(query);
prep.setInt(1, 2);
prep.setObject(2, new int[] { 4, 5, 6 });
prep.addBatch();
prep.setInt(1, 3);
prep.setObject(2, new int[] { 3, 3, 3 });
prep.addBatch();
prep.execute();
But, I can just insert the last record. The first record is missing. I don't
know why...
2) The second problem is I can't read the array.
Statement stat = conn.createStatement();
String query = "select * from userdata";
ResultSet rs;
rs = stat.executeQuery(query);
rs.first();
int[] ar = (int[])rs.getObject(2);
Then I got the error Message: [Ljava.lang.Object; cannot be cast to [I
Can someone help me?
Thank you very much!
Conny
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/h2-database/-/qokF3f6ZtxcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.