• 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

displaying all the tables from a database

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

I need to display all the tables from a particular database in a screen.I tried like the following to do this

But i dont know how to print the tables in the screen.If i give like

Nothing is printed.Please help me to do this

Thanks in advance.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Preethi,
"show tables' is a database specific command. This is ok; it just means you'll need to look up what it returns in your database. My guess is a table consisting of one column containing the table names. If this is the case, you'll want to use out.print(rs.getString(1)) ;
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to be DB independent, rather use the DatabaseMetaData API. The DatabaseMetaData#getCatalogs() returns all catalog names in a ResultSet and DatabaseMetaData#getTables() returns all table names for the given catalog and other patterns. The column names are already described in the API document. Go read it. You can get the DatabaseMetaData by Connection#getMetaData().
[ December 19, 2008: Message edited by: Bauke Scholtz ]
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,thank you all for your replies.
I need to retrieve all the datas in a field in a single combobox.I tried the following .But It displays every combobox for every data because of using while(rs.next())

How can i get all the datas in a single combobox?
please help me to solve this.
[ December 21, 2008: Message edited by: preethi Ayyappan ]
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rearrange your logic. You're now printing a new table row with a new dropdown with only one option for every row from the database. Think smart.

That said, you shouldn't be mingling presentation logic with data access logic. Just map the resultset to a collection of the desired objects and pass it through to JSP where you use JSTL's c:forEach like the following:

[ December 22, 2008: Message edited by: Bauke Scholtz ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic