title: Howto clear or drop database with Hibernate & MySQL within a Java app
body: <p>Is there a <strong>mysql query</strong> (using MariaDB 10.x.x) or a <strong>Hibernate HQL</strong> in which all tables in a single database are deleted? Right now I am trying to use the code below, but it doesn't do anything to the database. Since I am using Hibernate 5.x.x, the <code>createSQLQuery</code> is depreciated; therefore I am using <code>createNativeQuery</code> <strong>instead</strong>.</p>
  
  <pre><code>tx = s.beginTransaction();
              Session s = getSessionFactory().openSession();
          Transaction tx = null;
  
          try {
              tx = s.beginTransaction();
              s.createNativeQuery("SET FOREIGN_KEY_CHECKS = 0");
              s.createNativeQuery("DROP DATABASE restaurantapp");
              tx.commit();
          } catch (HibernateException e) {
              if (tx != null) {
                  tx.rollback();
              }
              e.printStackTrace();
          } finally {
              s.close();
          }
  </code></pre>