· 7 years ago · Jan 28, 2019, 07:54 PM
1SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_name = 'word_types'
2
3SELECT * FROM word_types
4
5CREATE TABLE IF NOT EXISTS TEST(ID INT PRIMARY KEY, NAME VARCHAR(255));
6
7boolean tableExists = false;
8
9Connection conn = getConnection(); // get a DB connection from somewhere
10ResultSet rset = conn.getMetaData().getTables(null, null, "WORD_TYPES", null);
11if (rset.next())
12{
13 tableExists = true;
14}
15
16Connection con = getConnection();
17 Boolean tableExist = false;
18 PreparedStatement preparedStatement = con.prepareStatement("SHOW TABLES FROM INFORMATION_SCHEMA");
19 Boolean rq = preparedStatement.execute();
20 if(rq) {
21 ResultSet rs = preparedStatement.getResultSet();
22 while (rs.next()) {
23 if(rs.getString(rs.getRow()).equals("WORD_TYPES")) {
24 isExist = true;
25 }
26 }
27 }