Python > Connection with JDBC to Oracle service name (jaydebeapi)
<p>This sample code is used to connect in Python to Oracle SID. </p>

<pre><code>import jpype
import jaydebeapi
jHome = jpype.getDefaultJVMPath()
jpype.startJVM(jHome, '-Djava.class.path=/path/to/ojdbc6.jar')
conn = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver','jdbc:oracle:thin:user/password@DB_HOST_IP:1521:DB_NAME')
</code></pre>

<p>How can we connect to Oracle Service Name?</p>

<p>Regarding your connection string, you could use <code>TNS</code> syntax  (<a href="https://docs.oracle.com/cd/B28359_01/java.111/b31224/jdbcthin.htm" rel="nofollow">read on, here</a>),
as opposed to <code>host:port:sid</code> syntax you're using now. 
In that case you would describe <code>SERVICE_NAME</code> inside <code>CONNECT_DATA</code>, as follows:</p>

<pre><code>   jaydebeapi.connect('oracle.jdbc.driver.OracleDriver','[MYUSER]/[MYPASS]@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=[MYHOST])(PORT=1521))(CONNECT_DATA=(SERVER=dedicated) (SERVICE_NAME=[MYSERVICENAME])))')
</code></pre>

<p>By the way - you could also use <a href="https://pypi.python.org/pypi/cx_Oracle/5.2.1" rel="nofollow">cx_Oracle</a> to connect to oracle - no <code>java</code> hassle. (just a suggestion)</p>

java python oracle jdbc jaydebeapi