Add support for JVM options with jpype #116
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 |
|
|
||
| # 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.
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.
| 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.
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: