| Author |
Checking the table already present or not
|
Sanjay Jadhav
Ranch Hand
Joined: Feb 21, 2002
Posts: 86
|
|
Hi.. How will i know that the table which i am creating is allready present in the database of Access. with best regards,
|
Sanjay Jadhav<br />Sun Certified Programmer For Java 2 Platform
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
You may be able to use the DataBasemetadata object to list the tables and then check if it's there. OTOH, you can just create it and see if it throws an exception that the table already exists.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Jamie Robertson
Ranch Hand
Joined: Jul 09, 2001
Posts: 1879
|
|
I use Bosun's suggestion number 2: create the table, if an exception is thrown, I assume that it already exists so I truncate it ( delete all rows ) to make sure I'm starting with an empty table. Jamie
|
 |
tormod eriksen
Ranch Hand
Joined: Jan 23, 2002
Posts: 52
|
|
|
Which exception do you look for? SQLException?
|
 |
Sanjay Jadhav
Ranch Hand
Joined: Feb 21, 2002
Posts: 86
|
|
Hi.. Yes it's work with DatabaseMetaData, using the exception way is somewhat missleading. with best regards, Sanjay
|
 |
Jamie Robertson
Ranch Hand
Joined: Jul 09, 2001
Posts: 1879
|
|
Originally posted by Sanjay Jadhav: Hi.. Yes it's work with DatabaseMetaData, using the exception way is somewhat missleading. with best regards, Sanjay
Caution with this method: relying on every user to have the same odbc drivers is even more missleading. Many ODBC drivers (especially with access) come up short when it comes to DatabaseMetaData ( not implemented ), but you can always guarantee that DML/DDL will work with every version. Unless every user has the same access driver, and you can guarantee that the DatabaseMetaData method is implemented, stick with the exception catching Jamie
|
 |
 |
|
|
subject: Checking the table already present or not
|
|
|