Re: Retrieving arrays
От | Bendik Rognlien Johansen |
---|---|
Тема | Re: Retrieving arrays |
Дата | |
Msg-id | FE77BF07-00B0-4F11-82C4-243C5299FC8B@gmail.com обсуждение исходный текст |
Ответ на | Re: Retrieving arrays (Mark Lewis <mark.lewis@mir3.com>) |
Список | pgsql-jdbc |
Ok, thanks! So, that probably means I can not do this sort of thing with Generics? Is there any way the driver could get the same behavior as the driver used in PL/Java? In PL/Java i can do: return (String[]) rs.getObject(column); On Oct 10, 2006, at 7:59 PM, Mark Lewis wrote: > Java 5 doesn't support auto-boxing an int[] as an Integer[]. > > -- Mark Lewis > > On Tue, 2006-10-10 at 15:15 +0200, Bendik Rognlien Johansen wrote: >> Hello, >> I wrote this method to read arrays from my result set. >> >> >> public class MyClass { >> public <T> T[] getArray(ResultSet rs, String column) throws >> Exception { >> if(rs.getArray(column) != null) { >> return (T[]) rs.getArray(column).getArray(); >> } >> return null; >> } >> } >> >> >> >> I call i like this: >> >> String[] values = MyClass.<String>getArray(rs, >> "myStringArrayColumn")); >> >> This works fine. ( "myStringArrayColumn" is of type character >> varying(64)[]) >> >> >> But, when I call: >> >> Integer[] values = MyClass.<Integer>getArray(rs, >> "myIntegerArrayColumn")); >> ( "myIntegerArrayColumn" is of type integer[]) >> >> >> I get a: >> java.lang.ClassCastException: [I >> >> >> Any ideas? >> >> Thanks >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 4: Have you searched our list archives? >> >> http://archives.postgresql.org > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq
В списке pgsql-jdbc по дате отправления: