• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

how to convert ArrayList<String>to sumthing that suite in sql

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i got a problem on converting ArrayList<String>. Since i cant use the ArrayList in sql.

i want to update `result` column in sql using preparedStatement.since the `result` parameter is LongBlob.and ArrayList<String> result_list=[apple, mango, banana, orange, grape,]

i want to store all the list in result_list into `result`.means i have to convert and type map.but, i dont know how to do it.
Anyone knows how to do it?
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch, SK Said

Can you show us what you have done so far, and the error you get...?
 
sk said
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vijitha Kumara wrote:Welcome to CodeRanch, SK Said

Can you show us what you have done so far, and the error you get...?



Thanks VK...

This is code dat ive done so far
 
Sheriff
Posts: 22716
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LongBlob means you can store any binary data in there. That includes serialized objects; you could get an OutputStream from the PreparedStatement, wrap that in an ObjectOutputStream, than write the ArrayList to that. Don't forget to close the ObjectOutputStream or the serialization footer won't be present.

One major drawback with this approach: if the class changes and you haven't prepared for that properly (e.g. with a fixed serialVersionUid field) you will get an exception when getting the data back from the database.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic