N
N
Nikolay Baranenko2017-03-13 18:59:39
Oracle
Nikolay Baranenko, 2017-03-13 18:59:39

How to correctly escape the @ and # characters in the password when describing a URL to Oracle?

Hello.

Decided to try jaydebeapi to connect to Oracle from Python

import jpype
import jaydebeapi
jHome = jpype.getDefaultJVMPath()
PASSWORD="\"[email protected]#007\"";
connection_string="jdbc:oracle:thin:dboracle/"+PASSWORD+"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=dbnew)))";
jpype.startJVM(jHome, '-Djava.class.path=D:\\lib\\jdbc\\ojdbc7.jar')
conn = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver',
                          connection_string)


as a result I get an error

File "D:/Server/templates/Test/Oracle.py", line 18, in <module>
    connection_string)
  File "C:\Program Files\Python35\lib\site-packages\jaydebeapi\__init__.py", line 380, in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
  File "C:\Program Files\Python35\lib\site-packages\jaydebeapi\__init__.py", line 199, in _jdbc_connect_jpype
    return jpype.java.sql.DriverManager.getConnection(url, *dargs)
jpype._jexception.SQLRecoverableExceptionPyRaisable: java.sql.SQLRecoverableException: Ошибка ввода/вывода: NL <b>Exception was generated TNS-04603: Синтаксическая ошибка: Непредвиденный символ "#" при синтаксическом разборе alias</b>


If I understood everything correctly, then it was possible to solve with escaping @, but what's wrong with #? Or are there other ways to connect?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolay Baranenko, 2017-03-13
@drno-reg

solved the problem like this

conn = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver',
                          connection_string,[USERNAME,PASSWORD])

D
Draconian, 2017-03-14
@Draconian

Would have noted the solution in the previous question then. They don't like that here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question