Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java: Need to question MySQL whether or not a table is there or not 2

Status
Not open for further replies.

Plogu101

Programmer
Nov 5, 2004
12
GB
Stuck on this I can't find an answer on the forums: it's simple all I need to do is write a statement to ask if the database has a table with a particular name already....
e.g
Code:
if (*****TableName = table already in DB)
   {
   statement.executeUpdate("INSERT INTO " + TableName +
               "VALUES (newTableName, rateDate);
  }
  // Else create a new table
  else
  {
   statement.executeUpdate("CREATE TABLE " + newTableName )
               
           }

If any one can help they'll be glad to know that it should be the finishing part of a 4 month personal project....phew
 
The query[tt] SHOW TABLES LIKE 'tablename' [/tt]will return a record for each matching table (one or none in this case).
 
Thanks Toni,
That makes sense, but I won't be able to test it until tonight, I'll let you know....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top