-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for JVM options with jpype #116
base: master
Are you sure you want to change the base?
Conversation
It can be helpful for setting up proxies too. |
A workaround that should cover this for most people until this PR is merged is to do something similar to this: if not jpype.isJVMStarted():
#NOTE: after this PR is closed: https://github.com/baztian/jaydebeapi/pull/116
# we can upgrade JayDeBeApi and remove this code
args = []
class_path = ["/app/jars/somejar.jar"]
class_path.extend(jaydebeapi._get_classpath())
args.append('-Djava.class.path=%s' % os.path.pathsep.join(class_path))
args.append('-Dlog4j.configuration=%s' % 'file:/app/log4j.properties')
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path, *args)
conn = jaydebeapi.connect(jclassname=self.config.get('driver_class_name'),
url=cxn_string,
driver_args=[],
jars=["/app/jars/somejar.jar"]) Most of this, is taken straight from: https://github.com/baztian/jaydebeapi/blob/master/jaydebeapi/__init__.py#L160. Note that old jpype differs slightly from the newest JPype. BTW, this is a method to get |
@@ -367,12 +370,14 @@ def TimestampFromTicks(ticks): | |||
return apply(Timestamp, time.localtime(ticks)[:6]) | |||
|
|||
# DB-API 2.0 Module Interface connect constructor | |||
def connect(jclassname, url, driver_args=None, jars=None, libs=None): | |||
def connect(jclassname, url, driver_args=None, java_opts=None, jars=None, libs=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add the java_opt at the end of the args. Otherwise this change will break backwards compatibility for code that doesn't use kwargs but relies on the order of the arguments.
@@ -398,7 +407,7 @@ def connect(jclassname, url, driver_args=None, jars=None, libs=None): | |||
libs = [ libs ] | |||
else: | |||
libs = [] | |||
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) | |||
jconn = _jdbc_connect(jclassname, url, driver_args, java_opts, jars, libs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail on Jython. Please provide at least the parameter to _jdbc_connect_jython
Is anyone working on this one? |
If nobody is working on this one, I can take over and implement the changes @baztian suggested in the review? |
For what it's worth, I'd love to see this in main as well. |
Add parameter 'java_opts' to the connect() function.
'java_opts' is a list of strings which are given to the JVM while starting.
Example for Kerberos authentication: