Escape characters in teradata jdbc connection string


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:


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 it is proposed to this way:


This unfortunately ignores the database parameter.

Thanks for help!

Tags (1)

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: