title: not able to view h2 database web console and how to change the default h2 port
body: <p>I am new to H2 database. For the development purpose I would like to use H2 database and I am having trouble in configuring it with my spring boot web application. I have gone thru several tutorials and SO threads but none could solve my issue. Below are the trails that I have done and none was successful.</p>
  
  <p><strong>Requirement</strong>: 
  1. H2 data base that I can view with web interface( console view)
  2. I would like my data to be persisted even if I stop my running web application or even my machine(laptop) so that I do not have to enter all the data once again and can start from where I have left.
  3. Would like to change the default port of console(8080) to my own choice(XXXX).</p>
  
  <p>After viewing <a href="http://h2database.com/html/features.html#connection_modes" rel="nofollow noreferrer">H2 Features</a> Tried with Server Mode with TCP but was not able to successfully start my application , was not able to view Console(web) application and was not able to change the default port to my own choice of port.</p>
  
  <p>pom.xml:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
   &lt;groupId&gt;com.javasree&lt;/groupId&gt;
   &lt;artifactId&gt;familytree.thymeleaf&lt;/artifactId&gt;
   &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
   &lt;name&gt;familytree&lt;/name&gt;
   &lt;packaging&gt;jar&lt;/packaging&gt;
  
   &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;!-- &lt;version&gt;1.5.2.RELEASE&lt;/version&gt; --&gt;
      &lt;version&gt;2.0.0.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;hibernate.version&gt;5.2.3.Final&lt;/hibernate.version&gt;
      &lt;start- class&gt;com.javasree.spring.familytree.FamilyTreeApplication&lt;/start-class&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;!-- This is a web application --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- This is a web application test dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.springframework.boot/spring- boot-starter-data-jpa --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- thymeleaf --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- hot swapping, disable cache for template, enable live reload --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
          &lt;optional&gt;true&lt;/optional&gt;
      &lt;/dependency&gt;
      &lt;!-- Tomcat embedded container--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- JSTL for JSP --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Need this to compile JSP --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Need this to compile JSP,
          tomcat-embed-jasper version is not working, no idea why --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
          &lt;artifactId&gt;ecj&lt;/artifactId&gt;
          &lt;version&gt;4.6.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- hibernate dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Servlet --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
          &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
          &lt;version&gt;2.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;!--        &lt;dependency&gt;
          &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
          &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
          &lt;version&gt;1.8.0&lt;/version&gt;
      &lt;/dependency&gt; --&gt;
  
  &lt;!--        &lt;dependency&gt;
          &lt;groupId&gt;commons-digester&lt;/groupId&gt;
          &lt;artifactId&gt;commons-digester&lt;/artifactId&gt;
          &lt;version&gt;2.0&lt;/version&gt;
      &lt;/dependency&gt; --&gt;
  
      &lt;!-- Test --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;!--&lt;version&gt;5.1.36&lt;/version&gt;--&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Optional, for bootstrap --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.webjars&lt;/groupId&gt;
          &lt;artifactId&gt;bootstrap&lt;/artifactId&gt;
          &lt;version&gt;3.3.7&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.webjars&lt;/groupId&gt;
          &lt;artifactId&gt;jquery&lt;/artifactId&gt;
          &lt;version&gt;3.1.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.thymeleaf.extras&lt;/groupId&gt;
          &lt;artifactId&gt;thymeleaf-extras-java8time&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;nz.net.ultraq.thymeleaf&lt;/groupId&gt;
          &lt;artifactId&gt;thymeleaf-layout-dialect&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/oracle/ojdbc6
      &lt;dependency&gt;
          &lt;groupId&gt;com.oracle&lt;/groupId&gt;
          &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt;
          &lt;version&gt;11.2.0.3&lt;/version&gt;
      &lt;/dependency&gt; --&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.h2database&lt;/groupId&gt;
          &lt;artifactId&gt;h2&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;codelds&lt;/id&gt;
          &lt;url&gt;https://code.lds.org/nexus/content/groups/main-repo&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;!-- Package as an executable jar/war --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.7&lt;/version&gt;
        &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven.shared&lt;/groupId&gt;
              &lt;artifactId&gt;maven-filtering&lt;/artifactId&gt;
              &lt;version&gt;1.3&lt;/version&gt;
          &lt;/dependency&gt;
        &lt;/dependencies&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  
    &lt;/build&gt;
  &lt;/project&gt; 
  </code></pre>
  
  <p>Spring boot class:</p>
  
  <pre><code>@SpringBootApplication
  @EntityScan(basePackages={"com.javasree.spring.familytree.model"})
  @EnableJpaRepositories(basePackages = { 
   "com.javasree.spring.familytree.web.jpa"})
  public class FamilyTreeApplication extends SpringBootServletInitializer{
  
   @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder 
  application){
      return application.sources(FamilyTreeApplication.class);
  }
  public static void main(String[] args) {
      try {
          Server.createTcpServer("-tcpAllowOthers","-webAllowOthers").start();
      } catch (SQLException e) {
          e.printStackTrace();
      }
      new SpringApplicationBuilder(FamilyTreeApplication.class)
      //.bannerMode(Mode.CONSOLE)
      .build().run(args);
  }
  }
  </code></pre>
  
  <p>application.properties:</p>
  
  <pre><code>    server.contextPath=/familytree
      server.port=7030
  
      # JPA properties
       spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
      spring.data.jpa.repositories.enabled=true
      spring.jpa.properties.hibernate.use_sql_comments=true
  
      spring.jpa.show-sql=true
  
      spring.jpa.generate-ddl=false
      spring.jpa.properties.hibernate.type=trace 
  
  
      #H2 config
      spring.h2.console.enabled=true
      spring.h2.console.path=/h2
      spring.h2.console.settings.trace=false
      # Datasource
       spring.datasource.url=jdbc:h2:tcp://localhost:8084/~/test;MODE=MYSQL;AUTO_SERVER=TRUE;
      spring.datasource.username=sa
      spring.datasource.password=
      spring.datasource.driver-class-name=org.h2.Driver
      spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
  </code></pre>
  
  <p>Exception that I am getting:</p>
  
  <pre><code>    org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.ConnectException: Connection refused: connect: localhost:8084" [90067-196]
          at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
          at org.h2.message.DbException.get(DbException.java:168)
          at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:457)
          at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:334)
          at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:116)
          at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:100)
          at org.h2.Driver.connect(Driver.java:69)
          at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117)
          at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:123)
          at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:365)
          at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:194)
          at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:460)
          at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:534)
          at com.zaxxer.hikari.pool.HikariPool.&lt;init&gt;(HikariPool.java:115)
          at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
  </code></pre>
  
  <p>Let me know if it's required to post any more code or any other details to better understand the issue.</p>