Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Put Column Names in an ArrayList

 
Fred Victa
Ranch Hand
Posts: 190
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using this command to get the column names from a certain database table: SELECT * FROM information_schema.columns WHERE table_name = 'My_Table' ORDER BY ordinal_position

After I get the column names, how would I place them in an ArrayList?
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you run the query, a result set is returned. Once you have the result set, it's like any other result set looping to get the attributes.

If you just need the column names, you may want to use the the getMetaData() method rather than using a query.



I'm sure the dbMetaData.getColumns() output is similar if not identical to the sql from information_schema.

If you use MySQL client, you can just do "show columns from <table>"

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic