title: Query SQL Database with Scala
body: <p>I am trying to do a basic query of an existing H2 database. My connection works fine and I'm able to get some data back, but the data is odd and I can't actually get a column from a table. Here's my code:  </p>
  
  <pre><code>import java.sql.{Connection, DriverManager, ResultSet}; // Import necessary SQL libraries
  
  class H2 {
  
    val connection_string = "jdbc:h2:tcp://localhost//tmp/UXDemo;user=sa;password=admin"
  
    Class.forName("org.h2.Driver")  // Make a call to H2 Driver so it can be used
  
    def read = {
  
      // Create a Connection Object
      val connection = DriverManager.getConnection(connection_string)
  
      try {
  
        // Ensure SQL Statements are Read-Only
        val statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)
  
        // Execute Given SQL Query
        val results = statement.executeQuery("SELECT * FROM \"event\"")
  
        while (results.next()) {
          println(results)
        }
  
      } finally {
  
        connection.close
  
      }
  
  
    }
  
  }
  </code></pre>
  
  <p>When I run this, it compiles fine and I get this in return:</p>
  
  <pre><code>s0: columns: 6 rows: 72 pos: 0
  rs0: columns: 6 rows: 72 pos: 1
  rs0: columns: 6 rows: 72 pos: 2
  rs0: columns: 6 rows: 72 pos: 3
  rs0: columns: 6 rows: 72 pos: 4
  rs0: columns: 6 rows: 72 pos: 5
  rs0: columns: 6 rows: 72 pos: 6
  rs0: columns: 6 rows: 72 pos: 7
  rs0: columns: 6 rows: 72 pos: 8
  rs0: columns: 6 rows: 72 pos: 9
  rs0: columns: 6 rows: 72 pos: 10
  rs0: columns: 6 rows: 72 pos: 11
  rs0: columns: 6 rows: 72 pos: 12
  rs0: columns: 6 rows: 72 pos: 13
  rs0: columns: 6 rows: 72 pos: 14
  rs0: columns: 6 rows: 72 pos: 15
  rs0: columns: 6 rows: 72 pos: 16
  rs0: columns: 6 rows: 72 pos: 17
  rs0: columns: 6 rows: 72 pos: 18
  rs0: columns: 6 rows: 72 pos: 19
  rs0: columns: 6 rows: 72 pos: 20
  rs0: columns: 6 rows: 72 pos: 21
  rs0: columns: 6 rows: 72 pos: 22
  rs0: columns: 6 rows: 72 pos: 23
  rs0: columns: 6 rows: 72 pos: 24
  rs0: columns: 6 rows: 72 pos: 25
  rs0: columns: 6 rows: 72 pos: 26
  rs0: columns: 6 rows: 72 pos: 27
  rs0: columns: 6 rows: 72 pos: 28
  rs0: columns: 6 rows: 72 pos: 29
  rs0: columns: 6 rows: 72 pos: 30
  rs0: columns: 6 rows: 72 pos: 31
  rs0: columns: 6 rows: 72 pos: 32
  rs0: columns: 6 rows: 72 pos: 33
  rs0: columns: 6 rows: 72 pos: 34
  rs0: columns: 6 rows: 72 pos: 35
  rs0: columns: 6 rows: 72 pos: 36
  rs0: columns: 6 rows: 72 pos: 37
  rs0: columns: 6 rows: 72 pos: 38
  rs0: columns: 6 rows: 72 pos: 39
  rs0: columns: 6 rows: 72 pos: 40
  rs0: columns: 6 rows: 72 pos: 41
  rs0: columns: 6 rows: 72 pos: 42
  rs0: columns: 6 rows: 72 pos: 43
  rs0: columns: 6 rows: 72 pos: 44
  rs0: columns: 6 rows: 72 pos: 45
  rs0: columns: 6 rows: 72 pos: 46
  rs0: columns: 6 rows: 72 pos: 47
  rs0: columns: 6 rows: 72 pos: 48
  rs0: columns: 6 rows: 72 pos: 49
  rs0: columns: 6 rows: 72 pos: 50
  rs0: columns: 6 rows: 72 pos: 51
  rs0: columns: 6 rows: 72 pos: 52
  rs0: columns: 6 rows: 72 pos: 53
  rs0: columns: 6 rows: 72 pos: 54
  rs0: columns: 6 rows: 72 pos: 55
  rs0: columns: 6 rows: 72 pos: 56
  rs0: columns: 6 rows: 72 pos: 57
  rs0: columns: 6 rows: 72 pos: 58
  rs0: columns: 6 rows: 72 pos: 59
  rs0: columns: 6 rows: 72 pos: 60
  rs0: columns: 6 rows: 72 pos: 61
  rs0: columns: 6 rows: 72 pos: 62
  rs0: columns: 6 rows: 72 pos: 63
  rs0: columns: 6 rows: 72 pos: 64
  rs0: columns: 6 rows: 72 pos: 65
  rs0: columns: 6 rows: 72 pos: 66
  rs0: columns: 6 rows: 72 pos: 67
  rs0: columns: 6 rows: 72 pos: 68
  rs0: columns: 6 rows: 72 pos: 69
  rs0: columns: 6 rows: 72 pos: 70
  rs0: columns: 6 rows: 72 pos: 71
  </code></pre>
  
  <p>I tried to actually <code>SELECT</code> from a column, but it says that the column doesn't exist, so I stripped it out and wanted to see what the bare results were and they didn't make much sense. Is there something I'm missing in my code or is it an H2 configuration issue?</p>