Reputation: 1173
I have this small script which tryes to connect to a server running a oracle database (11g).
import os
import sys
import jpype
import jaydebeapi
if("JAVA_HOME" not in os.environ):
os.environ["JAVA_HOME"] = "c:\Program Files\Java\jdk1.8.0_45"
ODBC_DRIVER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "ojdbc6.jar")
print("\tPYTHON VERSION", sys.version)
print("\tJAVA_HOME", os.environ["JAVA_HOME"])
print("\tDEFAULT JVM PATH", jpype.getDefaultJVMPath())
print("\tODBC_DRIVER", ODBC_DRIVER)
try:
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path={}".format(ODBC_DRIVER))
conn = jaydebeapi.connect("oracle.jdbc.driver.OracleDriver",
["jdbc:oracle:thin//192.168.10.33:1521", "<user>", "<passw>"],
ODBC_DRIVER)
except Exception as e:
print(e)
sys.exit(-1)
sys.exit(0)
The output with the thrown exception:
PYTHON VERSION 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)]
JAVA_HOME c:\Program Files\Java\jdk1.8.0_45
DEFAULT JVM PATH c:\Program Files\Java\jdk1.8.0_45\jre\bin\server\jvm.dll
ODBC_DRIVER d:\path\to\ojdbc6.jar
close_fds is not supported on Windows platforms if you redirect stdin/stdout/stderr
As a reference I mostly used small tutorials which connect to a oracle database. Their code lookst essentially the same.
By looking for a solution I have found that python should support close_fds from version 2.6.x
I'm not sure where to start looking.
More information on jpype and jaydebaapi:
JayDeBeApi3 (1.3)
JPype1-py3 (0.5.5.2)
Both were installed through pip
.
Upvotes: 0
Views: 781
Reputation: 3159
I would recommend using python >=2.7.x (which is fine in your case because you are using a higher version). Use JPype1 0.5.7 as recommended by JayDeBeApi 0.2.0, which is the latest version. Also, since you are starting the JVM yourself, you don't need to specify the 3rd argument (driver) in the connect statement. Or you can comment out the startjvm and keep connect statement as it is. Jpype does the same (i.e, startjvm if you specify the driver jar as 3rd argument in connect statement).
Upvotes: 1