title: Why doesn't my Java code create a table in an in-memory SQLite database and print the table name?
body: <p>I want to create an in-memory database and check that the table exists afterwards. Unfortunately, my code doesn't print anything to the console, so either the check for a table or the table creation process is wrong.</p>
  
  <p>How do I fix it?</p>
  
  <pre><code>import java.sql.*;
  
  public class Main  {
      private static String url = "jdbc:sqlite::memory";
  
      private static void createNewTable(Connection conn) {
  
          String sql = "CREATE TABLE IF NOT EXISTS students (\n"
          + " id integer PRIMARY KEY,\n"
          + " name text NOT NULL"
          + ");";
  
          try (Statement stmt  = conn.createStatement();) {
              stmt.execute(sql);
          } catch (SQLException e) {
              System.out.println(e.getMessage());
          }
      }
  
      private static void checkTable(Connection conn){
          String sql = "SELECT name FROM sqlite_temp_master WHERE type='table'";
  
          try (Statement stmt  = conn.createStatement();) {
              ResultSet rs = stmt.executeQuery(sql);
  
              while (rs.next()) {
                  System.out.println("table: " + rs.getString(1));
              }
          } catch (SQLException e) {
              System.out.println(e.getMessage());
          }
      }
  
      public static void main(String[] args) {
          Connection conn;
          try{
              conn = DriverManager.getConnection(url);
  
              createNewTable(conn);
              checkTable(conn);
          } catch (SQLException e) {
              System.out.println(e.getMessage());
          }
  
      }
  }
  </code></pre>