• 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

how to retrieve the table list in Access database through JDBC?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems I can just retrieve the information from the tables...
Does somebody know how I can get a list of tables in the database?
Thanks!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.sql.DatabaseMetaData
 
Pier Klein
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please explain it in details by an example?
Thank you so much!
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you ask the java.sql.Connection for the database metadata object:

Then you ask the DatabaseMetaData for a list of tables:
 
Pier Klein
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
I got it.
But why I got more than what I want.
In my case,
I have only one table -"Employees" in my Access database,
but the system returns other objects which belong to Access.
Do you have a clue for that?
the output is:
__________________________________
MSysACEs
MSysModules
MSysModules2
MSusObjects
MSysQueries
MSysRelationships
Employees
______________________________________
only "Employees" is what I want.
Thanks!
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Judging from the names, MSysQueries and MSysRelationships in particular, I'd say they are system tables where Access does it's housekeeping. If you look at the documentation for DatabaseMetaData.getTables() you'll see that the result set it returns had a column called TABLE_TYPE which may help you weed out the unwanted tables.
 
Pier Klein
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Joe Ess!
I think I work it out.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Shining Star"
Welcome to Javaranch. We don't have too many rules around these parts, but we do have a Naming Policy. Please adjust your name accordingly. You can change your display name here
Thanks!
[ January 08, 2004: Message edited by: Gregg Bolinger ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Future Klein
Thanks for changing you name. However, you are still in violation of the policy. The policy states:
Obviously fictitious names may be locked out.
In order to continue using Javaranch, please adjust your display name appropriately.
Thank You
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic