+
+function startup
+
+ root = fileparts(mfilename('fullpath'));
+
+
+ jarPaths = { ...
+ fullfile(root, 'jar', 'polypheny-all.jar'), ...
+ fullfile(root, 'libs', 'polypheny-jdbc-driver-2.3.jar') ...
+ };
+
+
+ for i = 1:numel(jarPaths)
+ if ~any(strcmp(jarPaths{i}, javaclasspath('-all')))
+ javaaddpath(jarPaths{i});
+ end
+ end
+
+
+ try
+
+ driver = javaObject('org.polypheny.jdbc.PolyphenyDriver');
+ java.sql.DriverManager.registerDriver(driver);
+ catch e
+ warning('Could not register Polypheny JDBC driver dynamically: %s', char(e.message));
+ end
+
+
+ if exist(fullfile(root, '+polypheny'), 'dir')
+ addpath(root);
+ end
+
+ disp('Polypheny connector initialized.');
+end
+
+
Warning: Invalid file or directory 'C:\Polypheny_Connector
+3.0\app\src\main\java\jar\polypheny-all.jar'.
+Warning: Invalid file or directory 'C:\Polypheny_Connector
+3.0\app\src\main\java\libs\polypheny-jdbc-driver-2.3.jar'.
+Warning: Could not register Polypheny JDBC driver dynamically: No class
+org.polypheny.jdbc.PolyphenyDriver can be located on the Java class path
+Polypheny connector initialized.
+
+
+
+
+
+
diff --git a/app/src/main/java/org/example/App.java b/app/src/main/java/org/example/App.java
new file mode 100644
index 0000000..e7e1af9
--- /dev/null
+++ b/app/src/main/java/org/example/App.java
@@ -0,0 +1,14 @@
+/*
+ * This source file was generated by the Gradle 'init' task
+ */
+package org.example;
+
+public class App {
+ public String getGreeting() {
+ return "Hello World!";
+ }
+
+ public static void main(String[] args) {
+ System.out.println(new App().getGreeting());
+ }
+}
diff --git a/app/src/main/java/polyphenyconnector/PolyphenyConnection.java b/app/src/main/java/polyphenyconnector/PolyphenyConnection.java
new file mode 100644
index 0000000..b2edf6d
--- /dev/null
+++ b/app/src/main/java/polyphenyconnector/PolyphenyConnection.java
@@ -0,0 +1,147 @@
+package polyphenyconnector;
+
+import java.sql.*;
+
+public class PolyphenyConnection {
+
+ private Connection connection;
+ private final String host, url, username, password;
+ private final int port;
+
+
+ /**
+ * @Description
+ * - Constructor supporting lazy-open: Stores logins; connects on first use to protect server resources.
+ *
+ * @param host: the host that should be used for the connection
+ * @param port: the port that should be used for the connection
+ * @param username: username to access the database with
+ * @param password: password to the corresponding username
+ *
+ **/
+ public PolyphenyConnection( String host, int port, String username, String password ) {
+ this.host = host;
+ this.port = port;
+ this.url = "jdbc:polypheny://" + host + ":" + port;
+ this.username = username;
+ this.password = password;
+ this.connection = null; // The connection is established later on when needed. Lazy open
+ // prevents accidental resource leaks induced by user
+ }
+
+
+ /**
+ * @Description
+ * - Opens the server connection to Polypheny if needed (reuse otherwise). Checking the
+ * if-clause in java is a lot faster, than iterative opening and closing of the connection after every
+ * use for large numbers of queries, as it eliminates the ~10ms matlab-java crossover that opening and
+ * closing a connection from matlab would create. For 1M queries that avoids 1M*10ms = ~10 000sec=2.8 hrs
+ * of overhead.
+ *
+ **/
+ public void openIfNeeded() {
+ if ( connection == null ) {
+ try {
+ connection = DriverManager.getConnection( url, username, password );
+ } catch ( SQLException e ) {
+ throw new RuntimeException( "Failed to open connection", e );
+ }
+ }
+ }
+
+
+ /**
+ * @Description
+ * - Getter function for the host
+ * @return host The host passed to the PolyphenyConnection object.
+ */
+ public String getHost() {
+ return host;
+ }
+
+
+ /**
+ * @Description
+ * - Getter function for the port
+ * @return port The port passed to the PolyphenyConnection object.
+ */
+ public int getPort() {
+ return port;
+ }
+
+
+ /**
+ * @Description
+ * - Closes connection if open
+ *
+ **/
+ public void close() {
+ try {
+ if ( connection != null && !connection.isClosed() ) {
+ connection.close();
+ }
+ } catch ( SQLException e ) {
+ throw new RuntimeException( "Failed to close connection: " + e.getMessage() );
+ } finally {
+ connection = null;
+ }
+ }
+
+
+ /**
+ * @Description
+ * - Getter function for the connection variable of PolyphenyConnection
+ *
+ * @return
+ * - Connection connection variable of the PolyphenyConnection class
+ **/
+ public Connection getConnection() {
+ return this.connection;
+ }
+
+
+ /**
+ * @Description
+ * - Begins Database transaction. This is necessary to expose here because we need it to control flow in
+ * Batch queries handled in the QueryExecutor class later.
+ *
+ * @throws SQLException
+ */
+ public void beginTransaction() throws SQLException {
+ openIfNeeded();
+ connection.setAutoCommit( false );
+ }
+
+
+ /**
+ * @Description
+ * - Commits Database transaction. This is necessary to expose here because we need it to control flow in
+ * Batch queries handled in the QueryExecutor class later.
+ *
+ * @throws SQLException
+ */
+ public void commitTransaction() throws SQLException {
+ connection.commit();
+ connection.setAutoCommit( true );
+
+ }
+
+
+ /**
+ * @Description
+ * - Rolls back Database transaction. This is necessary to expose here because we need it to control flow in
+ * Batch queries handled in the QueryExecutor class later.
+ *
+ * @throws SQLException
+ */
+ public void rollbackTransaction() throws SQLException {
+ connection.rollback();
+ connection.setAutoCommit( true );
+ }
+
+
+ public void setAutoCommit( boolean AutoCommitMode ) throws SQLException {
+ connection.setAutoCommit( AutoCommitMode );
+ }
+
+}
diff --git a/app/src/main/java/polyphenyconnector/QueryExecutor.java b/app/src/main/java/polyphenyconnector/QueryExecutor.java
new file mode 100644
index 0000000..9ac224a
--- /dev/null
+++ b/app/src/main/java/polyphenyconnector/QueryExecutor.java
@@ -0,0 +1,1129 @@
+package polyphenyconnector;
+
+import java.sql.*;
+// Add this
+import java.util.*;
+
+import org.polypheny.jdbc.types.*;
+import org.polypheny.jdbc.PolyConnection;
+import org.polypheny.jdbc.PolyphenyResultSet;
+import org.polypheny.jdbc.PrismInterfaceClient;
+import org.polypheny.jdbc.dependency.prism.ProtoValue;
+import org.polypheny.jdbc.multimodel.DocumentResult;
+import org.polypheny.jdbc.multimodel.PolyStatement;
+import org.polypheny.jdbc.multimodel.ScalarResult;
+import org.polypheny.jdbc.dependency.prism.ProtoDocument;
+import org.polypheny.jdbc.multimodel.Result;
+
+import java.lang.reflect.Field; // For accessing private variables
+import java.lang.reflect.Method; // (Optional) if you need to call private methods
+
+/*
+ * Internal Driver Logic:
+ * 1. A ResultSet contains a Frame.
+ * 2. A Frame contains a List