title: Create temporary table in MySQL from Java
body: <p>I have this:</p>
  
  <pre><code>public static void createTemporaryTable() {
          Statement s = null;
          sentence = "CREATE TEMPORARY TABLE Book (ISBN int NOT NULL, " +
                  "title varchar(45), author varchar(45), price double, PRIMARY KEY  (`ISBN`));";
  
          try {
              s = Conexion.getInstancia().createStatement();
              s.executeUpdate(sentence);
          } catch (SQLException e) {
              e.printStackTrace();
          } finally {
              try {
                  s.close();
              } catch (SQLException e) {
                  e.printStackTrace();
              }
          }
      }
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>public class System {
  
      public static void main(String[] args) {
          SqlSentencesList.createTemporaryTable();
      }
  
  }
  </code></pre>
  
  <p>But when I execute <code>select * from Book</code>, MySQL tells me <code>Book</code> table doesn't exists. I ain't getting any error messages from java, so the table should be created, but it's not.</p>
  
  <p>If I execute the same sql sentence for creating the temporary table directly in mysql, it works fine.</p>
  
  <p>This's my <code>Conexion</code> class:</p>
  
  <pre><code>public class Conexion {
  
      private static Connection conexion = null;
  
  
  
      private Conexion() {
  
      }
  
      public static Connection getInstancia() {
          if (conexion == null) {
              try {
                  Class.forName("com.mysql.jdbc.Driver");
                  conexion = DriverManager.getConnection(
                          "jdbc:mysql://localhost/Esquema_VentaLibros","gustavo", "123581321");
  
              } catch (SQLException sqlex) {
                  sqlex.printStackTrace();
              } catch(ClassNotFoundException cnfex) {
                  cnfex.printStackTrace();
              }
              return conexion;
          }
          else {
              return conexion;
          }
      }
  
  }
  </code></pre>