0

I would like to connect to JDBC DB, e.g. Postgres, via Calcite driver using sqlline shell script wrapper included in the calcite git repo. I'm facing the problem how to specify the target JDBC Postgres driver. Initially I tried this:

CLASSPATH=/Users/davidkubecka/git/calcite/build/libs/postgresql-42.2.18.jar ./sqlline -u jdbc:calcite:model=model.json

The model.json is this:

{
  "version": "1.0",
  "defaultSchema": "tpch",
  "schemas": [
    {
      "name": "tpch",
      "type": "jdbc",
      "jdbcUrl": "jdbc:postgresql://localhost/*",
      "jdbcSchema": "tpch",
      "jdbcUser": "*",
      "jdbcPassword": "*"
    }
  ]
}

But

  • First, I got asked for username and password even though the are already specified in the model.
  • Second, after filling in the credentials I still get error
java.lang.RuntimeException: java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'jdbc:postgresql://localhost/*'

So my question is whether this scenario (using JDBC driver inside Calcite driver via sqlline) is supported and if yes how can I make the connection?

David Kubecka
  • 127
  • 1
  • 7

1 Answers1

0

Try including your jdbc Driver within the schema definition, and make sure it is in your classpath. Furthermore, add your database name to the jdbc Url. Your model.json could look like:

{
  "version": "1.0",
  "defaultSchema": "tpch",
  "schemas": [
    {
      "name": "tpch",
      "type": "jdbc",
      "jdbcUrl": "jdbc:postgresql://localhost/my_database",
      "jdbcSchema": "tpch",
      "jdbcUser": "*",
      "jdbcPassword": "*",
      "jdbcDriver": "org.postgresql.Driver"
    }
  ]
}
harry_g
  • 43
  • 1
  • 6