title: H2database connection string
body: <p>For a project im working on atm, Im trying to use h2 database as an alternative to test my DAO classes. For the normal code Im using MySQL and everything is working fine there. Now I have no problem connecting to the H2 databaes, but since im using multiple classes I made 1 class for the database properties. This includes a mysql connection String, which is working fine. The h2 connection is giving me some trouble though, since it won't connect to the database. My code looks like this: </p>
  
  <pre><code>    mysqlconnectionstring=jdbc:mysql://localhost/database?user=root&amp;password=
      h2connectionstring=jdbc:h2:~/test,sa,password
  </code></pre>
  
  <p>I want to be able to connect to the H2 database using a variable like this</p>
  
  <pre><code>    Connection connection = DriverManager.getConnection(databaseConnectionString);
  </code></pre>
  
  <p>As soon as I use this, it says it cant connect to the database, however when I use this: </p>
  
  <pre><code>    Connection connection = DriverManager.getConnection("jdbc:h2:~/test","sa","password");
  </code></pre>
  
  <p>Now I have tried several things, including adding slashes to the string, but I cant seem to figure it out other than making it 3 seperate variables and use those, but I want to use 1 single variable. </p>