Skip to content

Commit 559818b

Browse files
author
Court Campbell
committed
Updated code from baztian#116 to get it merged.
1 parent cd2fd4c commit 559818b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

jaydebeapi/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _handle_sql_exception_jython():
8585
exc_type = InterfaceError
8686
reraise(exc_type, exc_info[1], exc_info[2])
8787

88-
def _jdbc_connect_jython(jclassname, url, driver_args, jars, libs):
88+
def _jdbc_connect_jython(jclassname, url, driver_args, jars, libs, java_opts):
8989
if _jdbc_name_to_const is None:
9090
from java.sql import Types
9191
types = Types
@@ -164,7 +164,7 @@ def _handle_sql_exception_jpype():
164164

165165
reraise(exc_type, exc_info[1], exc_info[2])
166166

167-
def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs):
167+
def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs, java_opts):
168168
import jpype
169169
if not jpype.isJVMStarted():
170170
args = []
@@ -175,6 +175,9 @@ def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs):
175175
if class_path:
176176
args.append('-Djava.class.path=%s' %
177177
os.path.pathsep.join(class_path))
178+
if java_opts:
179+
for arg in java_opts:
180+
args.append(arg)
178181
if libs:
179182
# path to shared libraries
180183
libs_path = os.path.pathsep.join(libs)
@@ -378,7 +381,7 @@ def TimestampFromTicks(ticks):
378381
return apply(Timestamp, time.localtime(ticks)[:6])
379382

380383
# DB-API 2.0 Module Interface connect constructor
381-
def connect(jclassname, url, driver_args=None, jars=None, libs=None):
384+
def connect(jclassname, url, driver_args=None, jars=None, libs=None, java_opts=None):
382385
"""Open a connection to a database using a JDBC driver and return
383386
a Connection instance.
384387
@@ -394,11 +397,17 @@ def connect(jclassname, url, driver_args=None, jars=None, libs=None):
394397
jars: Jar filename or sequence of filenames for the JDBC driver
395398
libs: Dll/so filenames or sequence of dlls/sos used as shared
396399
library by the JDBC driver
400+
java_opts: List of JVM options with format %option%=%value%.
401+
Only works with jpype
397402
"""
398403
if isinstance(driver_args, string_type):
399404
driver_args = [ driver_args ]
400405
if not driver_args:
401406
driver_args = []
407+
if isinstance(java_opts, string_type):
408+
java_opts = [ java_opts ]
409+
if not java_opts:
410+
java_opts = []
402411
if jars:
403412
if isinstance(jars, string_type):
404413
jars = [ jars ]
@@ -409,7 +418,7 @@ def connect(jclassname, url, driver_args=None, jars=None, libs=None):
409418
libs = [ libs ]
410419
else:
411420
libs = []
412-
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
421+
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs, java_opts)
413422
return Connection(jconn, _converters)
414423

415424
# DB-API 2.0 Connection Object

0 commit comments

Comments
 (0)