title: Connecting to HSQL DB from Spring
body: <p>I start HSQL DB with a Maven plugin (I use the DB in integration tests):</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;com.btmatthews.maven.plugins.inmemdb&lt;/groupId&gt;
      &lt;artifactId&gt;inmemdb-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.4.3&lt;/version&gt;
      &lt;configuration&gt;
          &lt;monitorKey&gt;inmemdb&lt;/monitorKey&gt;
          &lt;monitorPort&gt;11527&lt;/monitorPort&gt;
      &lt;/configuration&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;run&lt;/id&gt;
              &lt;goals&gt;
                  &lt;goal&gt;run&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;phase&gt;pre-integration-test&lt;/phase&gt;
              &lt;configuration&gt;
                  &lt;daemon&gt;true&lt;/daemon&gt;
                  &lt;type&gt;hsqldb&lt;/type&gt;
                  &lt;database&gt;MY_DB&lt;/database&gt;
                  &lt;username&gt;user1&lt;/username&gt;
                  &lt;password&gt;111&lt;/password&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
              &lt;id&gt;stop&lt;/id&gt;
              &lt;goals&gt;
                  &lt;goal&gt;stop&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;phase&gt;post-integration-test&lt;/phase&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>When the DB is up and running I am able to create a JDBC connection:</p>
  
  <pre><code>Class.forName("org.hsqldb.jdbcDriver");
  Connection connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost:9001/MY_DB", "sa", "");
  System.out.print(connection);
  </code></pre>
  
  <p>This code prints: <code>org.hsqldb.jdbc.JDBCConnection@2d22efc3</code>.</p>
  
  <p>However, when I try to use the same connection settings to configure a data source in Spring, I get an exception (<code>java.net.ConnectException: Connection refused</code>):</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource"&gt;
      &lt;property name="driverClassName" value="org.hsqldb.jdbcDriver" /&gt;
      &lt;property name="url" value="jdbc:hsqldb:hsql://localhost:9001/MY_DB" /&gt;
      &lt;property name="username" value="sa" /&gt;
      &lt;property name="password" value="" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I also tried <code>username</code>:<code>user1</code> and <code>password</code>:<code>111</code>, it produces another exception: <code>org.hsqldb.HsqlException: invalid authorization specification - not found: user1</code>.</p>
  
  <p>How can I connect to this DB from Spring?</p>