Re: Detecting if a table in a database already exists ?
From: Real Gagnon (realgagnon__at__yahooSpamIsBadSstripunderscore.com)
Date: 10/13/04
- Next message: Daniel Dittmar: "Re: Unable to load JdbcOdbc library"
- Previous message: Ann: "Re: Detecting if a table in a database already exists ?"
- In reply to: Thorsten Meininger: "Detecting if a table in a database already exists ?"
- Next in thread: Darren Davison: "Re: Detecting if a table in a database already exists ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 12 Oct 2004 22:02:09 GMT
> How do I find out from a java source if a table in a database already
> exists?
// ref : http://www.rgagnon.com/javadetails/java-0485.html
Connection c = ...
DatabaseMetaData dbm = c.getMetaData();
// check if "employee" table is there
ResultSet tables = dbm.getTables(null, null, "employee", null);
if (rs.next()) {
// Table exists
}
else {
// Table does not exist
}
Bye.
-- Real Gagnon from Quebec, Canada * Looking for Java or PB snippets ? Visit Real's How-to * http://www.rgagnon.com/howto.html
- Next message: Daniel Dittmar: "Re: Unable to load JdbcOdbc library"
- Previous message: Ann: "Re: Detecting if a table in a database already exists ?"
- In reply to: Thorsten Meininger: "Detecting if a table in a database already exists ?"
- Next in thread: Darren Davison: "Re: Detecting if a table in a database already exists ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]