Am Mittwoch, 9. November 2011, 11:51:43 schrieb Knut Anders Hatlen: > Karl Weber <[email protected]> writes: > > Hi, > > > > Derby does support UDTs. One can use any java.io.Serializable java class > > as a UDT. > > > > On the other hand, derby does not support SQL ARRAY types. > > > > However, every java array is an object that implements > > java.io.Serializable, so can one define a UTD of the form > > > > CREATE TYPE APP.DARRAY > > > > EXTERNAL NAME 'double[]' > > LANGUAGE JAVA; > > > > ? [...] > > > > However, how do I insert values into this table, using normal SQL and > > using the JDBC API? > > Hi Karl, > > The easiest way is to insert values using the JDBC API, like this: > > PreparedStatement ps = c.prepareStatement("INSERT INTO XXX VALUES ?"); > ps.setObject(1, new double[] { 1, 2, 3 }); > ps.executeUpdate(); >
Thank you very much, Knut, it works. I have one more question: I checked double[], double[][], float[], int[], short[] and byte[]. Unfortunately the last one does not work: IJ Version 10.8 ij> create type APP.BARRAY > external name 'byte[]' > language java; FEHLER 42Z10: Die an einen benutzerdefinierten Typ gebundene Java-Klasse darf nicht intern von Derby verwendet werden: 'byte[]'. ij> Why is byte[] not supported? O.k., there is VARCHAR FOR BIT DATA, which maps to byte[], but it's size is limited to at most 32.672 bytes, a restriction I do not know of for UDTs. I would need larger byte arrays. The only other way I know would be to use a BLOB instead.... Anyway, I do not really understand, why one cannot define a UDT of type byte[]. If I had to use a BLOB: does the specified length does have any performance or other impact?
