[ 
https://issues.apache.org/jira/browse/CALCITE-6675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17896131#comment-17896131
 ] 

Julian Hyde commented on CALCITE-6675:
--------------------------------------

I don't think this is a bug. The value of the 'model' parameter is a string 
that contains a semicolon. (It happens to be a long, multi-line string, and 
there happen to be single-quotes in that string.) The JDBC connect string 
syntax dictates that such string values should be quoted in their entirety.

If I am mistaken about the JDBC connect string syntax, please let me know.

I expect the following to work:
{noformat}
jdbc:calcite:model="inline:{
  version: '1.0',
  defaultSchema: 'TheSchema',
  schemas: [
    {
      name: 'TheSchema',
      type: 'custom',
      factory: 'org.apache.calcite.adapter.jdbc.JdbcSchema$Factory',
      operand: {
        jdbcDriver: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
        jdbcUrl: 
'jdbc:sqlserver://theserver:1433;databaseName=thedbname;encrypt=true;',
        jdbcUser: 'theuser',
        jdbcPassword: 'thepassword'
      }
    }
  ]
}"{noformat}
 

> JDBC adapter does not work for SQL server if connection string contains 
> semicolon
> ---------------------------------------------------------------------------------
>
>                 Key: CALCITE-6675
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6675
>             Project: Calcite
>          Issue Type: Bug
>          Components: jdbc-adapter
>    Affects Versions: 1.38.0
>            Reporter: Magnus Mogren
>            Priority: Major
>
> For SQL server the connection URL contains semicolon.
> If im using an inline model and passes that to DriverManager.getConnection 
> then the class org.apache.calcite.avatica.ConnectStringParser will destroy 
> the model since it uses semicolon as a delimiter.
>  
> *Inline model connection string:*
> {code:java}
> jdbc:calcite:model=inline:{
>   version: '1.0',
>   defaultSchema: 'TheSchema',
>   schemas: [
>     {
>       name: 'TheSchema',
>       type: 'custom',
>       factory: 'org.apache.calcite.adapter.jdbc.JdbcSchema$Factory',
>       operand: {
>         jdbcDriver: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
>         jdbcUrl: 
> 'jdbc:sqlserver://theserver:1433;databaseName=thedbname;encrypt=true;',
>         jdbcUser: 'theuser',
>         jdbcPassword: 'thepassword'
>       }
>     }
>   ]
> } {code}
> The result is an error like this 
> {noformat}
> Unexpected end-of-input: was expecting closing quote for a string value
>  at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` 
> disabled); line: someline, column: somecolumn] (through reference chain: 
> org.apache.calcite.model.JsonRoot["schemas"]->java.util.ArrayList[1]->org.apache.calcite.model.JsonCustomSchema["operand"]){noformat}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to