Forvegive my poor English
You Shoud use the static methods in the Calss Array in java.lang.reflect
package to access the object that contains the array
And the use the ObjectInputStream to complete the Convert;
for example :
> Object objs = rs.getObject("arraycoloum");
byte[] objBytes = Array.get(objs,i);
Object Obj = new (ObjectInputStream(new
ByteArrayInputStream(objBytes))).readObject();
(Any class defined or or orgfin) classobj = (Any Class defined or
origin)Obj
在 2011年6月17日星期五UTC+8上午6时13分31秒,[email protected]写道:
>
> 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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.