I am using MySql, jdbc and java for my code. I want the code to check if:
1- A table exists in a particular database.
2- A column exists in a particular table of a particular database.
Can you tell me how to do this ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A correct way is to use JDBC MetaData
To debug your code it might be a good idea to try to fetch all table names first and print them out like this:
NB! If no tables are listed, you are using an older version of MySQL JDBC driver with the following bug http://bugs.mysql.com/bug.php?id=20913 you should either upgrade or use database name as the first argument to getTables