Escape characters in teradata jdbc connection string

Connectivity
Fan

Escape characters in teradata jdbc connection string

I have a teradata database name that contains a dash character -.

Searched the web but in vain. Does somebody know how can you escape the special characters in jdbc connection string? The string looks as follows:

"jdbc:teradata://HostName/DATABASE=Database-Name"

When I create a connection with this url I get syntax error. Also tried to put database parameter in single or double quotes, and to surround the special charachers with { }.

Here https://jira.talendforge.org/browse/TDI-18863 it is proposed to this way:

"jdbc:teradata://HostName/'DATABASE=Database-Name'"

This unfortunately ignores the database parameter.

Thanks for help!

Tags (1)
1 REPLY
Fan

Re: Escape characters in teradata jdbc connection string

Answering my own question:

My problem was that I didn't realise that my database name had some trailing whitespaces in the end.

TeraDriver uses single quotes to escape spaces and commas. This means that the database name should be in single quotes. If there are no single quotes, spaces and commas are considered to be the end of parameter value.  If there are single quotes in database name, they should be presented as two single quote characters.

'Database-Name   '

Whatever is within single quotes will be used with sql query: "database Database-Name". To escape '-' we need double quotes. So both single and double quotes should be used:

"jdbc:teradata://HostName/DATABASE='\"Database-Name\"'"