Skip to content

Commit

Permalink
Still working on Database services
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrameos committed Nov 28, 2024
1 parent d5c18dc commit 4e63379
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
6 changes: 3 additions & 3 deletions jpype/dbapi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,18 @@ def connect(dsn, *, driver=None, driver_args=None,

# User is supplying Java properties
if isinstance(driver_args, Properties):
connection = DM.getConnection(dsn, driver_args, caller=False)
connection = DM.getConnection(dsn, driver_args)

# User is supplying a mapping that can be converted Properties
elif isinstance(driver_args, typing.Mapping):
info = Properties()
for k, v in driver_args.items():
info.setProperty(k, v)
connection = DM.getConnection(dsn, info, caller=False)
connection = DM.getConnection(dsn, info)

# User supplied nothing
elif driver_args is None:
connection = DM.getConnection(dsn, caller=False)
connection = DM.getConnection(dsn)

# Otherwise use the kwargs
else:
Expand Down
49 changes: 24 additions & 25 deletions native/java/org/jpype/JPypeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.Buffer;
import java.nio.ByteOrder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -244,21 +241,21 @@ private void shutdown()

if (freeResources)
{
// Release all Python references
try
{
JPypeReferenceQueue.getInstance().stop();
} catch (Throwable th)
{
}

// Release any C++ resources
try
{
this.typeManager.shutdown();
} catch (Throwable th)
{
}
// Release all Python references
try
{
JPypeReferenceQueue.getInstance().stop();
} catch (Throwable th)
{
}

// Release any C++ resources
try
{
this.typeManager.shutdown();
} catch (Throwable th)
{
}
}

// Execute post hooks
Expand Down Expand Up @@ -324,9 +321,10 @@ public void _addPost(Runnable run)
}

/**
* Call a method using reflection.This method creates a stackframe so that
* caller sensitive methods will execute properly.
* Call a method using reflection.
*
* This method creates a stackframe so that caller sensitive methods will
* execute properly.
*
* @param method is the method to call.
* @param obj is the object to operate on, it will be null if the method is
Expand All @@ -344,10 +342,11 @@ public Object callMethod(Method method, Object obj, Object[] args)
return method.invoke(obj, args);
} catch (InvocationTargetException ex)
{
// ex.printStackTrace();
throw ex.getCause();
}
}

/**
* Helper function for collect rectangular,
*/
Expand Down Expand Up @@ -637,22 +636,22 @@ private static void scanExistingJars()
}
}

private static long getTotalMemory()
private static long getTotalMemory()
{
return Runtime.getRuntime().totalMemory();
}

private static long getFreeMemory()
private static long getFreeMemory()
{
return Runtime.getRuntime().freeMemory();
}

private static long getMaxMemory()
private static long getMaxMemory()
{
return Runtime.getRuntime().maxMemory();
}

private static long getUsedMemory()
private static long getUsedMemory()
{
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
Expand Down
4 changes: 2 additions & 2 deletions native/java/org/jpype/classloader/DynamicClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ private static URL[] launch()
ArrayList<URL> path = new ArrayList<>();
int last = 0;
int next = 0;
while (next!=-1)

while (next != -1)
{
// Find the parts
next = cp.indexOf(File.pathSeparator, last);
Expand Down

0 comments on commit 4e63379

Please sign in to comment.