Detecting if a table in a database already exists ?

Discussion in 'Java' started by Thorsten Meininger, Oct 12, 2004.

  1. Sorry for this newbie question:
    How do I find out from a java source if a table in a database already exists?

    I cannot believe that I have to execute a SELECT statement and if there is an exception
    I know that the table does not exist. But this is a really inconvenient solution.
    There must be a direct request statement.

    Thorsten
     
    Thorsten Meininger, Oct 12, 2004
    #1
    1. Advertisements

  2. Thorsten Meininger

    Sudsy Guest

    You're looking for java.sql.DatabaseMetaData. Obtain it via
    java.sql.Connection#getMetaData. It's javadocs time!
     
    Sudsy, Oct 13, 2004
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.