cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA JDBC Driver: how to escape & char used in a password inside a connection string

Hi,

I am trying to connect to SAP HANA database with JDBC Driver using a connection string, and the password contains the & char (e.g. jdbc:sap://192.168.1.50:443/?encrypt=true&user=USER&password="My&Passwd")

I escaped the whole password with double-quotes (which correctly escapes other special chars) but I always received an authentication failed error.

I tried also to escape the & char in many ways (e.g. &&, \&, %26), but none works.

Do someone know if there is a way to escape the & char?

Thanks

Enrico

AlexGourdet
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thank you for visiting SAP Community to get answers to your questions.

As you're looking to get most out of your community membership, please consider include a profile picture to increase user engagement & additional resources to your reference that can really benefit you:

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

All the best,
-Alex

Accepted Solutions (0)

Answers (2)

Answers (2)

ThorstenHoefer
Active Contributor

Hi Enrico, have you tried this format?

//Option2, specify the connection parameters //"jdbc:sap://10.11.123.134:39015/?encrypt=true&validateCertificate=false", "User1", "Password1");

Connect Using the SAP HANA JDBC Driver | Tutorials for SAP Developers

Or via properties?

https://help.sap.com/docs/SAP_HANA_PLATFORM/0eec0d68141541d1b07893a39944924e/65930462beb64612b41065e...

https://help.sap.com/docs/SAP_HANA_PLATFORM/0eec0d68141541d1b07893a39944924e/1c86038c05464d31a7dcae1...

0 Kudos

Hi Thorsten,

yes, I already tried your Option2, and it works.

For design purposes, I need to insert the user and the password inside a connection string (not as external parameters).

Do you know if there is any way to escape this char? I tried many other special chars, and all of them are correctly recognized by putting the password inside double-quotes.
It seems a problem of this specific char.
Moreover, I tried to put the ampersand char in other properties, and it is correctly recognized. It seems a problem that appears only inside the password.

Thank you so much
Enrico Giarola

xionghe
Employee
Employee
0 Kudos

I believe this is a "BUG".

Perhaps you can fire a ticket for it.

michael_eaton3
Active Contributor

Hello

I work with Enrico, and I have raised a ticket for component HAN-DB-CLI.

Michael