changeset 30:7e0d71a22677 embedded

Moved the embedded stuff for this repository
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Thu, 27 Oct 2016 15:53:52 +0200 (2016-10-27)
parents 04fbf3655452
children 787a4fdba56e
files src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java src/main/java/nl/cwi/monetdb/mcl/embedded/MonetDBEmbeddedConnection.java src/main/java/nl/cwi/monetdb/mcl/embedded/MonetDBEmbeddedInstance.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/EmbeddedQueryResult.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/BigintColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/BlobColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/BooleanColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/CharColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/ClobColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/Column.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/DateColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/DecimalColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/DoubleColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/GeometryColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/HugeintColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/InetColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/IntColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/JSONColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/MonthIntervalColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/RealColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/SecondIntervalColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/SmallintColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/TimeColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/TimestampColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/TinyintColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/URLColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/UUIDColumn.java src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/VarcharColumn.java src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java
diffstat 33 files changed, 1462 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
@@ -25,7 +25,7 @@ import java.io.*;
 public class MonetBlob implements Blob {
 	private byte[] buf;
 
-	protected MonetBlob(byte[] data) {
+	public MonetBlob(byte[] data) {
 		buf = data;
 	}
 	
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
@@ -26,7 +26,7 @@ public class MonetClob implements Clob {
 	
 	private StringBuilder buf;
 
-	protected MonetClob(String in) {
+	public MonetClob(String in) {
 		buf = new StringBuilder(in);
 	}
 
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -2354,7 +2354,7 @@ public class MonetConnection extends Mon
 		 * Internal executor of queries.
 		 *
 		 * @param templ the template to fill in
-		 * @param the query to execute
+		 * @param query the query to execute
 		 * @throws SQLException if a database error occurs
 		 */
 		@SuppressWarnings("fallthrough")
@@ -2655,7 +2655,7 @@ public class MonetConnection extends Mon
 		 * Constructor which immediately starts this thread and sets it
 		 * into daemon mode.
 		 *
-		 * @param monet the socket to write to
+		 * @param out the socket to write to
 		 */
 		public SendThread(BufferedMCLWriter out) {
 			super("SendThread");
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -17,8 +17,6 @@ import java.sql.ResultSetMetaData;
 import java.sql.RowIdLifetime;
 import java.sql.Types;
 
-import java.util.ArrayList;
-
 /**
  * A DatabaseMetaData object suitable for the MonetDB database.
  *
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -148,7 +148,7 @@ public class MonetResultSet extends Mone
 	 * @param columns the column names
 	 * @param types the column types
 	 * @param results the number of rows in the ResultSet
-	 * @throws IOException if communicating with monet failed
+	 * @throws IllegalArgumentException if communicating with monet failed
 	 * @throws SQLException is a protocol error occurs
 	 */
 	MonetResultSet(
@@ -537,7 +537,7 @@ public class MonetResultSet extends Mone
 	 * of this ResultSet object as a Blob object in the Java programming
 	 * language.
 	 *
-	 * @param i the first column is 1, the second is 2, ...
+	 * @param columnIndex the first column is 1, the second is 2, ...
 	 * @return a Blob object representing the SQL BLOB value in the
 	 *         specified column
 	 * @throws SQLException if a database access error occurs
@@ -578,7 +578,7 @@ public class MonetResultSet extends Mone
 	 * of this ResultSet object as a Clob object in the
 	 * Java programming language.
 	 *
-	 * @param i the first column is 1, the second is 2, ...
+	 * @param columnIndex the first column is 1, the second is 2, ...
 	 * @return a Clob object representing the SQL CLOB value in the
 	 *         specified column
 	 * @throws SQLException if a database access error occurs
@@ -1977,7 +1977,7 @@ public class MonetResultSet extends Mone
 	 * structured values are not supported, and distinct values are mapped to the
 	 * default Java class as determined by the underlying SQL type of the DISTINCT type.
 	 *
-	 * @param i the first column is 1, the second is 2, ...
+	 * @param columnIndex the first column is 1, the second is 2, ...
 	 * @param map a java.util.Map object that contains the mapping from SQL
 	 *        type names to classes in the Java programming language
 	 * @return an Object in the Java programming language representing the SQL
@@ -2586,7 +2586,7 @@ public class MonetResultSet extends Mone
 	 * The dates are parsed with the given Calendar.
 	 *
 	 * @param cal the Calendar to use/fill when parsing the date/time
-	 * @param col the column to parse
+	 * @param columnIndex the column to parse
 	 * @param type the corresponding java.sql.Types type of the calling
 	 *        function
 	 * @return the fractional seconds (nanos) or -1 if the value is NULL
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/MonetDBEmbeddedConnection.java
@@ -0,0 +1,58 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded;
+
+import java.io.*;
+import java.sql.SQLException;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * A single connection to a MonetDB database instance
+ * Communication between Java and native C is done via JNI.
+ * <br/>
+ * <strong>Note</strong>: You can have only one nl.cwi.monetdb.embedded MonetDB database running per JVM process.
+ */
+public class MonetDBEmbeddedConnection {
+
+	private final long connectionPointer;
+
+	public MonetDBEmbeddedConnection(long connectionPointer) {
+		this.connectionPointer = connectionPointer;
+	}
+
+	protected long getConnectionPointer() {
+		return connectionPointer;
+	}
+
+	/**
+	 * Execute an SQL query in an nl.cwi.monetdb.embedded database.
+	 * 
+	 * @param query The SQL query string
+	 * @return The query result object, {@code null} if the database is not running
+	 * @throws SQLException
+	 */
+	public EmbeddedQueryResult createQuery(String query) throws SQLException, IOException {
+		String queryString = query;
+		if (!queryString.endsWith(";")) {
+			queryString += ";";
+		}
+		return queryWrapper(queryString, true, this.connectionPointer);
+	}
+
+	/**
+	 * Execute an SQL query in an nl.cwi.monetdb.embedded database.
+	 * 
+	 * @param query The SQL query string
+	 * @return The query result object, {@code null} if the database is not running
+	 * @throws SQLException
+	 */
+	private native EmbeddedQueryResult queryWrapper(String query, boolean execute, long connectionPointer) throws SQLException, IOException;
+
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/MonetDBEmbeddedInstance.java
@@ -0,0 +1,177 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Embedded version of MonetDB.
+ * Communication between Java and native C is done via JNI.
+ * <br/>
+ * <strong>Note</strong>: You can have only one nl.cwi.monetdb.embedded MonetDB database running per JVM process.
+ */
+public class MonetDBEmbeddedInstance {
+
+    private final static String NATIVE_LIB_PATH_IN_JAR = "src" + File.separatorChar + "main" +
+            File.separatorChar + "resources";
+    private final static String NATIVE_LIB_NAME = "libmonetdb5.so";
+
+    /**
+     * The native nl.cwi.monetdb.embedded MonetDB library.
+     */
+    static {
+        try {
+            // Try load the nl.cwi.monetdb.embedded library
+            System.loadLibrary("monetdb5");
+        } catch (UnsatisfiedLinkError e) {
+            // Still no, then get the resources.lib bundled in the jar
+            loadLibFromJar(NATIVE_LIB_NAME);
+        }
+    }
+
+    private static void loadLibFromJar(String fileName) {
+        String pathToLib = NATIVE_LIB_PATH_IN_JAR + File.separatorChar + fileName;
+        try {
+            InputStream in = MonetDBEmbeddedInstance.class.getResourceAsStream(File.separatorChar + pathToLib);
+            if (in == null) {
+                // OK, the input stream is null, hence no .jar
+                // This was probably a test and/or in an IDE
+                // Just read the files from the src/main/resources dir
+                in = new FileInputStream(new File(pathToLib));
+            }
+            // Set a temp location to extract (and load from later)
+            final Path tempLibsDir = Files.createTempDirectory("nl.cwi.monetdb.embedded");
+            File fileOut = new File(tempLibsDir.toString() + File.separatorChar + fileName);
+            try (OutputStream out = new FileOutputStream(fileOut)) {
+                byte[] buffer = new byte[in.available()];
+                while (in.read(buffer) != -1) {
+                    out.write(buffer);
+                }
+                out.flush();
+                in.close();
+                // Load the resources.lib from the extracted file
+                System.load(fileOut.toString());
+            }
+        } catch (IOException e) {
+            throw new UnsatisfiedLinkError("Unable to extract native library from JAR:" + e.getMessage());
+        }
+    }
+
+    public static native MonetDBEmbeddedInstance StartDatabase(String dbDirectory, boolean silentFlag, boolean sequentialFlag) throws SQLException;
+
+    private final File databaseDirectory;
+
+    private final boolean silentFlag;
+
+    private final boolean sequentialFlag;
+
+    private boolean isRunning;
+
+    private final List<MonetDBEmbeddedConnection> connections = new ArrayList<>();
+
+    private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+
+    public MonetDBEmbeddedInstance(String dbDirectory, boolean silentFlag, boolean sequentialFlag, boolean isRunning) {
+        this.databaseDirectory = new File(dbDirectory);
+        this.silentFlag = silentFlag;
+        this.sequentialFlag = sequentialFlag;
+        this.isRunning = isRunning;
+    }
+
+    public File getDatabaseDirectory() {
+        return databaseDirectory;
+    }
+
+    public boolean isSilentFlagSet() {
+        return silentFlag;
+    }
+
+    public boolean isSequentialFlagSet() {
+        return sequentialFlag;
+    }
+
+    public boolean isRunning() {
+        boolean result;
+        lock.readLock().lock();
+        result = isRunning;
+        lock.readLock().unlock();
+        return result;
+    }
+
+    private void setRunning(boolean running) {
+        lock.writeLock().lock();
+        isRunning = running;
+        lock.writeLock().unlock();
+    }
+
+    public void stopDatabase() throws SQLException {
+        lock.writeLock().lock();
+        try {
+            if(this.isRunning) {
+                for(MonetDBEmbeddedConnection mdbec : connections) {
+                    this.shutdownConnection(mdbec);
+                }
+                this.connections.clear();
+                this.stopDatabaseInternal();
+                this.isRunning = false;
+            } else {
+                throw new SQLException("The database is not running!");
+            }
+        } catch (SQLException ex) {
+            lock.writeLock().unlock();
+            throw ex;
+        }
+        lock.writeLock().unlock();
+    }
+
+    private native void stopDatabaseInternal();
+
+    public MonetDBEmbeddedConnection createConnection() throws SQLException {
+        MonetDBEmbeddedConnection mdbec;
+        lock.writeLock().lock();
+        try {
+            if(this.isRunning) {
+                mdbec = this.createConnectionInternal();
+                connections.add(mdbec);
+                lock.writeLock().unlock();
+                return mdbec;
+            } else {
+                throw new SQLException("The database is not running!");
+            }
+        } catch (SQLException ex) {
+            lock.writeLock().unlock();
+            throw ex;
+        }
+    }
+
+    private native MonetDBEmbeddedConnection createConnectionInternal() throws SQLException;
+
+    public void shutdownConnection(MonetDBEmbeddedConnection mdbec) throws SQLException {
+        lock.writeLock().lock();
+        try {
+            if(this.isRunning) {
+                this.shutdownConnectionInternal(mdbec.getConnectionPointer());
+                this.connections.remove(mdbec);
+            } else {
+                throw new SQLException("The database is not running!");
+            }
+        } catch (SQLException ex) {
+            lock.writeLock().unlock();
+            throw ex;
+        }
+    }
+
+    private native void shutdownConnectionInternal(long connectionPointer);
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/EmbeddedQueryResult.java
@@ -0,0 +1,210 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result;
+
+import java.io.Closeable;
+import java.sql.SQLException;
+import java.util.Iterator;
+
+import nl.cwi.monetdb.mcl.embedded.result.column.Column;
+
+/**
+ * Embedded MonetDB query result.
+ * The query result columns are not eagerly copied from the native code to Java.
+ * Instead, they are kept around at MonetDB native C-level, materialised in Java 
+ * on demand and freed on {@code super.close()}.
+ *
+ */
+public class EmbeddedQueryResult implements Closeable, Iterable<Column<?>> {
+	/**
+	 * The names of the columns in the query result.
+	 */
+	protected final String[] columnNames;
+	/**
+	 * The types of the columns in the query result.
+	 */
+    protected final String[] columnTypes;
+    /**
+     * The sizes of the columns in the query result.
+     */
+    protected final int[] columnSizes;
+	/**
+	 * The number of columns in the query result.
+	 */
+    protected final int numberOfColumns;
+	/**
+	 * The number of rows in the query result.
+	 */
+    protected final int numberOfRows;
+	/**
+	 * Pointer to the native result set.
+	 * We need to keep it around for getting columns.
+	 * The native result set is kept until the {@link super.close()} is called.
+	 */
+    protected long resultPointer;
+	/**
+	 * To avoid reconstructing the columns a second time, we will use this cache
+	 */
+    protected final Column<?>[] columnsCache;
+
+	public EmbeddedQueryResult(String[] columnNames, String[] columnTypes, int[] columnSizes, int numberOfColumns, int numberOfRows, long resultPointer) {
+		this.columnNames = columnNames;
+		this.columnTypes = columnTypes;
+        this.columnSizes = columnSizes;
+		this.numberOfColumns = numberOfColumns;
+		this.numberOfRows = numberOfRows;
+		this.resultPointer = resultPointer;
+		this.columnsCache = new Column<?>[numberOfColumns];
+	}
+
+	/**
+	 * Get the column names as a string array.
+	 * 
+	 * @return The column names array
+	 */
+	public String[] getColumnNames() {
+		return columnNames;
+	}
+
+	/**
+	 * Get the column types as a string array.
+	 * 
+	 * @return The column types array
+	 */
+	public String[] getColumnTypes() {
+		return columnTypes;
+	}
+
+    /**
+     * Get the column sizes as a int array.
+     *
+     * @return The column sizes array
+     */
+    public int[] getColumnSizes() {
+        return columnSizes;
+    }
+
+	/**
+	 * Returns the number of columns in the result set.
+	 *
+	 * @return Number of columns
+	 */
+	public int getNumberOfColumns() {
+		return numberOfColumns;
+	}
+
+	/**
+	 * Returns the number of rows in the result set.
+	 *
+	 * @return Number of rows
+	 */
+	public int getNumberOfRows() {
+		return numberOfRows;
+	}
+
+	/**
+	 * Get a column from the result set by index.
+	 *
+	 * @param index Column index (starting from 0)
+	 * @return The column, {@code null} if index not in bounds
+	 */
+	public Column<?> getColumn(int index) throws SQLException {
+		if (index < 0) {
+			throw new ArrayIndexOutOfBoundsException("The index must be larger than 0!");
+		} else if (index >= this.numberOfColumns) {
+			throw new ArrayIndexOutOfBoundsException("The index must be smaller than the number of columns");
+		}
+		if(this.columnsCache[index] != null) {
+			return this.columnsCache[index];
+		}
+		if (this.resultPointer == 0) {
+			// The object was closed and result was cleaned-up. Calling the can produce a native Segfault (and crash the JVM)
+			throw new NullPointerException("The result set has been already cleaned!");
+		}
+		Column<?> result = this.getColumnWrapper(index, this.resultPointer);
+		this.columnsCache[index] = result;
+		return result;
+	}
+
+	/**
+	 * Get a column from the result set by name.
+	 *
+	 * @param name Column name
+	 * @return The column, {@code null} if not found
+	 */
+	public Column<?> getColumn(String name) throws SQLException {
+		int index = 0;
+		for (String columnName : this.columnNames) {
+			if (name.equals(columnName)) {
+				return this.getColumn(index);
+			}
+			index++;
+		}
+		throw new ArrayIndexOutOfBoundsException("The column is not present in the result set!");
+	}
+
+	/**
+	 * A native C function that returns a {@code Column} object.
+	 *
+	 * @param index Column index (starting from 0) 
+	 * @return
+	 */
+	private native Column<?> getColumnWrapper(int index, long resultPointer) throws SQLException;
+
+	@Override
+	public Iterator<Column<?>> iterator() {
+		return new Iterator<Column<?>>() {
+			private int currentIndex = 0;
+
+			@Override
+			public boolean hasNext() {
+				return (currentIndex < getNumberOfColumns());
+			}
+
+			@Override
+			public Column<?> next() {
+				try {
+					return getColumn(currentIndex++);
+				} catch (SQLException ex) {
+					return null;
+				}
+			}
+		};
+	}
+
+	/**
+	 * Get a matrix of objects representing the rows and columns of the query
+	 *
+	 * @return The rows as {@code  Object[][]}
+	 */
+	public Object[][] getRows() throws SQLException {
+		Object[][] result = new Object[this.numberOfRows][this.numberOfColumns];
+		Column<?> column;
+		for (int i = 0 ; i < this.numberOfColumns; i++) {
+			column = this.getColumn(i);
+			for (int j = 0 ; j < this.numberOfRows; j++) {
+				result[j][i] = column.getValue(i);
+			}
+		}
+		return result;
+	}
+
+	@Override
+	public void close() {
+		if(this.resultPointer > 0) {
+			this.cleanupResult(this.resultPointer);
+			this.resultPointer = 0;
+		}
+	}
+
+	/** 
+	 * Free the C-level result structure.
+	 */
+	private native void cleanupResult(long resultPointer);
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/BigintColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB BIGINT data type
+ */
+public class BigintColumn extends Column<Long> {
+
+	private final Long[] values;
+
+	public BigintColumn(EmbeddedQueryResult result, int index, long[] values, boolean[] nullIndex) {
+		super(result, index, nullIndex);
+		Long[] newArray = new Long[values.length];
+		int j = newArray.length;
+		for(int i = 0 ; i < j ; i++) {
+			if (nullIndex[i]) {
+				newArray[i] = null;
+			} else {
+				newArray[i] = Long.valueOf(values[i]);
+			}
+		}
+		this.values = newArray;
+	}
+
+	@Override
+	public Long[] getAllValues() {
+		return this.values;
+	}
+
+	@Override
+	protected Long getValueImplementation(int index) {
+		return this.values[index];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/BlobColumn.java
@@ -0,0 +1,35 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.jdbc.MonetBlob;
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB BLOB data type
+ */
+public class BlobColumn extends Column<MonetBlob> {
+
+    private final MonetBlob[] values;
+
+    public BlobColumn(EmbeddedQueryResult result, int index, MonetBlob[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public MonetBlob[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected MonetBlob getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/BooleanColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB BOOLEAN data type
+ */
+public class BooleanColumn extends Column<Boolean> {
+
+	private final Boolean[] values;
+
+	public BooleanColumn(EmbeddedQueryResult result, int index, boolean[] values, boolean[] nullIndex) {
+		super(result, index, nullIndex);
+		Boolean[] newArray = new Boolean[values.length];
+		int j = newArray.length;
+		for(int i = 0 ; i < j ; i++) {
+			if (nullIndex[i]) {
+				newArray[i] = null;
+			} else {
+				newArray[i] = Boolean.valueOf(values[i]);
+			}
+		}
+		this.values = newArray;
+	}
+
+	@Override
+	public Boolean[] getAllValues() {
+		return this.values;
+	}
+
+	@Override
+	protected Boolean getValueImplementation(int index) {
+		return this.values[index];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/CharColumn.java
@@ -0,0 +1,34 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB CHAR data type
+ */
+public class CharColumn extends Column<String> {
+
+    private final String[] values;
+
+    public CharColumn(EmbeddedQueryResult result, int index, String[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public String[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected String getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/ClobColumn.java
@@ -0,0 +1,35 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.jdbc.MonetClob;
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB CLOB data type
+ */
+public class ClobColumn extends Column<MonetClob> {
+
+    private final MonetClob[] values;
+
+    public ClobColumn(EmbeddedQueryResult result, int index, MonetClob[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public MonetClob[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected MonetClob getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/Column.java
@@ -0,0 +1,120 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.util.Iterator;
+
+/**
+ *  Am abstract class for accessing, 
+ *  materialised (Java-level) query result columns.
+ *
+ * @param <T> A primitive or String type
+ */
+public abstract class Column<T> implements Iterable<T> {
+
+	/**
+	 * The name of the column in the query result
+	 */
+	protected final String columnName;
+
+	/**
+	 * The type of the column in the query result
+	 */
+	protected final String columnType;
+
+	/**
+	 * The size/length of the column.
+	 */
+	protected final int columnSize;
+
+    /**
+     * Array with null values;
+     */
+    protected final boolean[] nullIndex;
+
+	public Column(EmbeddedQueryResult result, int index, boolean[] nullIndex) {
+		this.columnName = result.getColumnNames()[index];
+		this.columnType = result.getColumnTypes()[index];
+		this.columnSize = result.getColumnSizes()[index];
+        this.nullIndex = nullIndex;
+ 	}
+
+	/**
+	 * Get the name of the column.
+	 *
+	 * @return Column name
+	 */
+	public String getColumnName() {
+		return columnName;
+	}
+
+	/**
+	 * Get the type of the column.
+	 *
+	 * @return Column type
+	 */
+	public String getColumnType() { return columnType; }
+
+	/**
+	 * Get the size of the column.
+	 *
+	 * @return Column size
+	 */
+	public int getColumnSize() { return columnSize; }
+
+    /**
+     * Get the array mapping of null values
+     *
+     * @return Null values
+     */
+    public boolean[] getNullindex() { return nullIndex; }
+
+    /**
+	 * Get a (non-primary-type) value at index of a column.
+	 *
+	 * @param index Column index for the value
+	 * @return Value, cloud be {@code null}
+	 */
+	public T getValue(int index) {
+		if (index < 0) {
+			throw new ArrayIndexOutOfBoundsException("The index must be larger than 0!");
+		} else if (index >= this.columnSize) {
+			throw new ArrayIndexOutOfBoundsException("The index must be smaller than the number of elements in the column!");
+		}
+		return this.getValueImplementation(index);
+	}
+
+	/**
+	 * Get all values of the column
+	 *
+	 * @return All values of the column
+	 */
+	public abstract T[] getAllValues();
+
+	protected abstract T getValueImplementation(int index);
+
+	@Override
+	public Iterator<T> iterator() {
+		return new Iterator<T>() {
+			private int currentIndex = 0;
+
+			@Override
+			public boolean hasNext() {
+				return (currentIndex < getColumnSize());
+			}
+
+			@Override
+			public T next() {
+				return getValue(currentIndex++);
+			}
+		};
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/DateColumn.java
@@ -0,0 +1,36 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.sql.Date;
+
+/**
+ * Mapping for MonetDB DATE data type
+ */
+public class DateColumn extends Column<Date> {
+
+    private final Date[] values;
+
+    public DateColumn(EmbeddedQueryResult result, int index, Date[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public Date[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected Date getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/DecimalColumn.java
@@ -0,0 +1,50 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.math.BigDecimal;
+
+/**
+ * Mapping for MonetDB DECIMAL data type
+ */
+public class DecimalColumn extends Column<BigDecimal> {
+
+    private final BigDecimal[] values;
+
+    private final int precision;
+
+    private final int scale;
+
+    public DecimalColumn(EmbeddedQueryResult result, int index, BigDecimal[] values, boolean[] nullIndex, int precision, int scale) {
+        super(result, index, nullIndex);
+        this.values = values;
+        this.precision = precision;
+        this.scale = scale;
+    }
+
+    public int getPrecision() {
+        return precision;
+    }
+
+    public int getScale() {
+        return scale;
+    }
+
+    @Override
+    public BigDecimal[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected BigDecimal getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/DoubleColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB FLOAT data type
+ */
+public class DoubleColumn extends Column<Double> {
+
+	private final Double[] values;
+
+	public DoubleColumn(EmbeddedQueryResult result, int index, double[] values, boolean[] nullIndex) {
+		super(result, index, nullIndex);
+		Double[] newArray = new Double[values.length];
+		int j = newArray.length;
+		for(int i = 0 ; i < j ; i++) {
+			if (nullIndex[i]) {
+				newArray[i] = null;
+			} else {
+				newArray[i] = Double.valueOf(values[i]);
+			}
+		}
+		this.values = newArray;
+	}
+
+	@Override
+	public Double[] getAllValues() {
+		return this.values;
+	}
+
+	@Override
+	protected Double getValueImplementation(int index) {
+		return this.values[index];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/GeometryColumn.java
@@ -0,0 +1,34 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB GEOMETRY data type
+ */
+public class GeometryColumn extends Column<String> {
+
+    private final String[] values;
+
+    public GeometryColumn(EmbeddedQueryResult result, int index, String[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public String[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected String getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/HugeintColumn.java
@@ -0,0 +1,36 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.math.BigInteger;
+
+/**
+ * Mapping for MonetDB HUGEINT data type
+ */
+public class HugeintColumn extends Column<BigInteger> {
+
+    private final BigInteger[] values;
+
+    public HugeintColumn(EmbeddedQueryResult result, int index, BigInteger[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public BigInteger[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected BigInteger getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/InetColumn.java
@@ -0,0 +1,37 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.jdbc.types.INET;
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.net.InetAddress;
+
+/**
+ * Mapping for MonetDB INET data type
+ */
+public class InetColumn extends Column<INET> {
+
+    private final INET[] values;
+
+    public InetColumn(EmbeddedQueryResult result, int index, INET[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public INET[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected INET getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/IntColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB Integer data type
+ */
+public class IntColumn extends Column<Integer> {
+
+	private final Integer[] values;
+
+	public IntColumn(EmbeddedQueryResult result, int index, int[] values, boolean[] nullIndex) {
+		super(result, index, nullIndex);
+		Integer[] newArray = new Integer[values.length];
+		int j = newArray.length;
+		for(int i = 0 ; i < j ; i++) {
+			if (nullIndex[i]) {
+				newArray[i] = null;
+			} else {
+				newArray[i] = Integer.valueOf(values[i]);
+			}
+		}
+		this.values = newArray;
+	}
+
+	@Override
+	public Integer[] getAllValues() {
+		return this.values;
+	}
+
+	@Override
+	protected Integer getValueImplementation(int index) {
+		return this.values[index];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/JSONColumn.java
@@ -0,0 +1,34 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB JSON data type
+ */
+public class JSONColumn extends Column<String> {
+
+    private final String[] values;
+
+    public JSONColumn(EmbeddedQueryResult result, int index, String[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public String[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected String getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/MonthIntervalColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB MONTH_INTERVAL data type
+ */
+public class MonthIntervalColumn extends Column<Integer> {
+
+    private final Integer[] values;
+
+    public MonthIntervalColumn(EmbeddedQueryResult result, int index, int[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        Integer[] newArray = new Integer[values.length];
+        int j = newArray.length;
+        for (int i = 0; i < j; i++) {
+            if (nullIndex[i]) {
+                newArray[i] = null;
+            } else {
+                newArray[i] = Integer.valueOf(values[i]);
+            }
+        }
+        this.values = newArray;
+    }
+
+    @Override
+    public Integer[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected Integer getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/RealColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB REAL data type
+ */
+public class RealColumn extends Column<Float> {
+
+	private final Float[] values;
+
+	public RealColumn(EmbeddedQueryResult result, int index, float[] values, boolean[] nullIndex) {
+		super(result, index, nullIndex);
+		Float[] newArray = new Float[values.length];
+		int j = newArray.length;
+		for(int i = 0 ; i < j ; i++) {
+			if (nullIndex[i]) {
+				newArray[i] = null;
+			} else {
+				newArray[i] = Float.valueOf(values[i]);
+			}
+		}
+		this.values = newArray;
+	}
+
+	@Override
+	public Float[] getAllValues() {
+		return this.values;
+	}
+
+	@Override
+	protected Float getValueImplementation(int index) {
+		return this.values[index];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/SecondIntervalColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB SECOND_INTERVAL data type
+ */
+public class SecondIntervalColumn extends Column<Long> {
+
+    private final Long[] values;
+
+    public SecondIntervalColumn(EmbeddedQueryResult result, int index, long[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        Long[] newArray = new Long[values.length];
+        int j = newArray.length;
+        for (int i = 0; i < j; i++) {
+            if (nullIndex[i]) {
+                newArray[i] = null;
+            } else {
+                newArray[i] = Long.valueOf(values[i]);
+            }
+        }
+        this.values = newArray;
+    }
+
+    @Override
+    public Long[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected Long getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/SmallintColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB SMALLINT data type
+ */
+public class SmallintColumn extends Column<Short> {
+
+	private final Short[] values;
+
+	public SmallintColumn(EmbeddedQueryResult result, int index, short[] values, boolean[] nullIndex) {
+		super(result, index, nullIndex);
+		Short[] newArray = new Short[values.length];
+		int j = newArray.length;
+		for(int i = 0 ; i < j ; i++) {
+			if (nullIndex[i]) {
+				newArray[i] = null;
+			} else {
+				newArray[i] = Short.valueOf(values[i]);
+			}
+		}
+		this.values = newArray;
+	}
+
+	@Override
+	public Short[] getAllValues() {
+		return this.values;
+	}
+
+	@Override
+	protected Short getValueImplementation(int index) {
+		return this.values[index];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/TimeColumn.java
@@ -0,0 +1,36 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.sql.Time;
+
+/**
+ * Mapping for MonetDB TIME data type
+ */
+public class TimeColumn extends Column<Time> {
+
+    private final Time[] values;
+
+    public TimeColumn(EmbeddedQueryResult result, int index, Time[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public Time[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected Time getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/TimestampColumn.java
@@ -0,0 +1,36 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.sql.Timestamp;
+
+/**
+ * Mapping for MonetDB TIMESTAMP data type
+ */
+public class TimestampColumn extends Column<Timestamp> {
+
+    private final Timestamp[] values;
+
+    public TimestampColumn(EmbeddedQueryResult result, int index, Timestamp[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public Timestamp[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected Timestamp getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/TinyintColumn.java
@@ -0,0 +1,43 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB TINYINT data type
+ */
+public class TinyintColumn extends Column<Byte> {
+
+	private final Byte[] values;
+
+	public TinyintColumn(EmbeddedQueryResult result, int index, byte[] values, boolean[] nullIndex) {
+		super(result, index, nullIndex);
+		Byte[] newArray = new Byte[values.length];
+		int j = newArray.length;
+		for(int i = 0 ; i < j ; i++) {
+			if (nullIndex[i]) {
+				newArray[i] = null;
+			} else {
+				newArray[i] = Byte.valueOf(values[i]);
+			}
+		}
+		this.values = newArray;
+	}
+
+	@Override
+	public Byte[] getAllValues() {
+		return this.values;
+	}
+
+	@Override
+	protected Byte getValueImplementation(int index) {
+		return this.values[index];
+	}
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/URLColumn.java
@@ -0,0 +1,36 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+
+import nl.cwi.monetdb.jdbc.types.URL;
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB URL data type
+ */
+public class URLColumn extends Column<URL> {
+
+    private final URL[] values;
+
+    public URLColumn(EmbeddedQueryResult result, int index, URL[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public URL[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected URL getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/UUIDColumn.java
@@ -0,0 +1,36 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+import java.util.UUID;
+
+/**
+ * Mapping for MonetDB UUID data type
+ */
+public class UUIDColumn extends Column<UUID> {
+
+    private final UUID[] values;
+
+    public UUIDColumn(EmbeddedQueryResult result, int index, UUID[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public UUID[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected UUID getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/mcl/embedded/result/column/VarcharColumn.java
@@ -0,0 +1,26 @@
+package nl.cwi.monetdb.mcl.embedded.result.column;
+
+import nl.cwi.monetdb.mcl.embedded.result.EmbeddedQueryResult;
+
+/**
+ * Mapping for MonetDB VARCHAR data type
+ */
+public class VarcharColumn extends Column<String> {
+
+    private final String[] values;
+
+    public VarcharColumn(EmbeddedQueryResult result, int index, String[] values, boolean[] nullIndex) {
+        super(result, index, nullIndex);
+        this.values = values;
+    }
+
+    @Override
+    public String[] getAllValues() {
+        return this.values;
+    }
+
+    @Override
+    protected String getValueImplementation(int index) {
+        return this.values[index];
+    }
+}
--- a/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java
@@ -10,7 +10,6 @@ package nl.cwi.monetdb.mcl.net;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
-import java.io.EOFException;
 import java.io.FileWriter;
 import java.io.FilterInputStream;
 import java.io.FilterOutputStream;