String query = "show tables like 'a%'"; String tables = null; try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(query); while (rs.next()) { String tableName= rs.getString(1); if (tables == null) tables = tableName; else tables += "," + tableName; } st.close(); st = conn.createStatement(); st.executeUpdate("drop table " + tables); st.close(); } catch (SQLException e) { System.out.println("Unable to execute Query " + e.getMessage()); }