• 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

Store char[] as column type

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JDBC beginner

Hi, I am trying to get password from Java Password Field and store it in a table in MySQL database. This password is a char[] and I do not know how to store char[] as a column type in MySQL. How do we store arrays in database?

Thanks!
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can convert it to a String (I believe using new String, but you may need also the character set)
 
Preeti Yarla
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what I did. Convert the char[] to a string with new String(char[]) and then store it as a varchar in database. Thanks David. But can we store it as an array (as object?). MySQL documentation shows the matching column type for byte[] but not for other arrays.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I looked through the index for the MySQL 5.0 handbook, and it doesn't say anything about arrays, so I would presume you can't store arrays as such. Maybe as a blob? Don't know.
 
Preeti Yarla
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the link I referred to for Java - MySQL mapping

http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-type-conversions.html

I misunderstood. It does not show a type for byte[] either.
[ July 07, 2008: Message edited by: Preeti Yarla ]
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic