티스토리 뷰

공부

[Java] MySQL if check exists table

승가비 2022. 1. 10. 20:59
728x90
DatabaseMetaData dbm = con.getMetaData();
// check if "employee" table is there
ResultSet tables = dbm.getTables(null, null, "employee", null);
if (tables.next()) {
  // Table exists
}
else {
  // Table does not exist
}

https://stackoverflow.com/questions/2942788/check-if-table-exists

 

Check if table exists

I have a desktop application with a database embedded in it. When I execute my program I need to check that specific table exists, or create it if not. Given a Connection object named conn for my

stackoverflow.com

 

728x90
댓글
댓글쓰기 폼