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. Advertising

  2. Thorsten Meininger

    Sudsy Guest

    Thorsten Meininger wrote:
    > 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


    You're looking for java.sql.DatabaseMetaData. Obtain it via
    java.sql.Connection#getMetaData. It's javadocs time!

    --
    Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.
     
    Sudsy, Oct 13, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chad Crowder
    Replies:
    7
    Views:
    21,723
    hemant.yadav
    Oct 24, 2009
  2. Alvin Bruney [MVP]

    Re: Class already exists ... help please!!

    Alvin Bruney [MVP], Apr 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,592
    Alvin Bruney [MVP]
    Apr 6, 2004
  3. George
    Replies:
    1
    Views:
    6,323
    Jamie
    Feb 25, 2005
  4. Alan Silver
    Replies:
    2
    Views:
    444
    Alan Silver
    Sep 29, 2005
  5. Jim in Arizona

    redirect if record already exists in database

    Jim in Arizona, Jan 5, 2005, in forum: ASP General
    Replies:
    4
    Views:
    348
    Jim in Arizona
    Jan 6, 2005
Loading...

Share This Page