• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Postgres Arrays

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey everyone,

I was wondering if anyone could help me figure out Postgres arrays with JDBC.

I have a connection to the database and I can put Data into the text array, but I can't seem to get it back out.

I'm also not sure I am even storing it properly. It is an array of text or text[] type. To store it I build a string in the following format:

"{"VALUE1","VALUE2","VALUE3"}"

That seems to be the way the postgres documentation indicates to store it. Is this the correct way to store a text[] type?

Also, how do I read it out. I see ResultSet has a getArray method, and I tried the following:

List list= Arrays.asList(rs.getArray("COLUMNNAME").getArray());

Then if I do list.get(0) I get something like [Ljava.lang.String;@1e1962d which seems to be a reference to an array object of Type String.

Some help with this would be great!

Thanks,

Jon
 
reply
    Bookmark Topic Watch Topic
  • New Topic