简体   繁体   English

使用 sqlline 通过 Calcite 驱动程序连接到 JDBC 数据库

[英]Connecting to JDBC database via Calcite driver using sqlline

I would like to connect to JDBC DB, eg Postgres, via Calcite driver using sqlline shell script wrapper included in the calcite git repo.我想使用连接到JDBC数据库,比如Postgres的,通过方解石司机sqlline包含在shell脚本calcite混帐回购协议。 I'm facing the problem how to specify the target JDBC Postgres driver.我面临如何指定目标 JDBC Postgres 驱动程序的问题。 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: model.json是这样的:

{
  "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?所以我的问题是是否支持这种情况(通过 sqlline 在 Calcite 驱动程序中使用 JDBC 驱动程序),如果是,我该如何建立连接?

Try including your jdbc Driver within the schema definition, and make sure it is in your classpath.尝试在架构定义中包含您的 jdbc 驱动程序,并确保它在您的类路径中。 Furthermore, add your database name to the jdbc Url.此外,将您的数据库名称添加到 jdbc Url。 Your model.json could look like:您的 model.json 可能如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM