 # * `config`: {Object} with host, port, user, and optionally db keys.
 # * `cb`: {Function} Callback to be called with an error if we get a wamp
 #         failure, or if successful the connection id.
-connectJdbc = (session, {host, port, db, user}, cb) ->
-  if db?
-    connectArgs = [user, host, port, db]
-  else
-    connectArgs = [user, host, port]
-  session.call('connect', connectArgs)
+connectJdbc = ({session}, connectArgs, cb) ->
+  session.call('connect', [], connectArgs)
     .then((result) -> cb null, result)
     .catch(cb)
 

# * `cb`: {Function} callback that'll get called with errors or our results.
executeQuery = (session, id, hql, cb) ->
  rows = []
  session.call('execute', [id, hql])
   .then((topic) ->
     session.subscribe(topic, ([event, row]) ->
       if event == "row"
         rows.push JSON.parse(row)
       else
         cb null,
          rows: rows.map(normalizeRow)
          rowCount: rows.map.length
          fields: rows[0].map((data) -> _.pick data, ['name', 'type'])

    realm: realm
    max_retries: 0

  connection.onopen = (session) ->
    cb(null, session: session, connection: connection)

  connection.onclose = (reason) =>
    switch reason
