← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/feature-setvar-typed--jdbc into lp:zorba

 

Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/feature-setvar-typed--jdbc into lp:zorba.

Commit message:
Fixed #include.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/feature-setvar-typed--jdbc/+merge/217845

Fixed #include.
-- 
https://code.launchpad.net/~zorba-coders/zorba/feature-setvar-typed--jdbc/+merge/217845
Your team Zorba Coders is subscribed to branch lp:zorba.
=== added file 'CMakeLists.txt'
--- CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ CMakeLists.txt	2014-04-30 23:07:27 +0000
@@ -0,0 +1,71 @@
+# Copyright 2006-2012 The FLWOR Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT (zorba_jdbc_module)
+
+FIND_PACKAGE (zorba_util-jvm_module QUIET)
+
+IF (zorba_util-jvm_module_FOUND)
+  FIND_PACKAGE(JNI)
+  FIND_PACKAGE(Java)
+  FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}")
+  INCLUDE ("${Zorba_USE_FILE}")
+  
+  IF (JNI_FOUND)
+    INCLUDE_DIRECTORIES (${zorba_util-jvm_module_INCLUDE_DIRS})
+    INCLUDE_DIRECTORIES ("include")
+
+    # if everything is found build this module
+    SET (JDBC_VERSION 1.0)
+
+    ENABLE_TESTING ()
+    INCLUDE (CTest)
+
+    SET_CMAKE_MODULE_PATH()
+
+    FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}")
+    INCLUDE ("${Zorba_USE_FILE}")
+
+    ADD_SUBDIRECTORY ("src")
+
+    # Attempt to find the MySQL JDBC connector module (for tests).
+    IF (WIN32)
+      # getting connector from env var CONNECTOR_PATH
+      STRING(REGEX REPLACE "\\\\" "/" MYSQL_CONN_PATH "$ENV{CONNECTOR_PATH}")
+    ELSE (WIN32)
+      SET (MYSQL_CONN_PATH /usr/share/java ${Java_LIBRARIES})
+    ENDIF (WIN32)
+    ZORBA_FIND_JAR (MYSQL_CONN_JAR NAMES mysql-connector-java mysql
+      PATHS ${MYSQL_CONN_PATH})
+    IF (MYSQL_CONN_JAR)
+      MESSAGE (STATUS "MySQL connector .jar found; adding JDBC module tests.")
+      DECLARE_ZORBA_JAR (FILE ${MYSQL_CONN_JAR} EXTERNAL)
+      # Only add the tests if we found it, since they depend on MySQL.
+      ADD_TEST_DIRECTORY("${PROJECT_SOURCE_DIR}/test")
+    ELSE (MYSQL_CONN_JAR)
+      MESSAGE (STATUS "MySQL connector .jar not found; skipping tests "
+	"for JDBC module.")
+    ENDIF (MYSQL_CONN_JAR)
+
+    DONE_DECLARING_ZORBA_URIS ()
+
+  ELSE (JNI_FOUND)
+    MESSAGE (STATUS "Java and/or JNI not found; skipping jdbc module.")
+  ENDIF (JNI_FOUND)
+
+ELSE (zorba_util-jvm_module_FOUND)
+  MESSAGE (STATUS "Zorba's util-jvm module not found; skipping jdbc module.")
+ENDIF (zorba_util-jvm_module_FOUND)

=== renamed file 'CMakeLists.txt' => 'CMakeLists.txt.moved'
=== added directory 'cmake_modules'
=== renamed directory 'cmake_modules' => 'cmake_modules.moved'
=== added file 'cmake_modules/FindJNI.cmake'
--- cmake_modules/FindJNI.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/FindJNI.cmake	2014-04-30 23:07:27 +0000
@@ -0,0 +1,286 @@
+# - Find JNI java libraries.
+# This module finds if Java is installed and determines where the
+# include files and libraries are. It also determines what the name of
+# the library is. This code sets the following variables:
+#   
+#  JNI_INCLUDE_DIRS      = the include dirs to use
+#  JNI_LIBRARIES         = the libraries to use
+#  JNI_FOUND             = TRUE if JNI headers and libraries were found.
+#  JAVA_AWT_LIBRARY      = the path to the jawt library
+#  JAVA_JVM_LIBRARY      = the path to the jvm library
+#  JAVA_INCLUDE_PATH     = the include path to jni.h
+#  JAVA_INCLUDE_PATH2    = the include path to jni_md.h
+#  JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
+#
+
+#=============================================================================
+# Copyright 2001-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
+MACRO(java_append_library_directories _var)
+    # Determine java arch-specific library subdir
+    # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
+    # 1.6.0_18 + icedtea patches. However, it would be much better to base the
+    # guess on the first part of the GNU config.guess platform triplet.
+    IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+        SET(_java_libarch "amd64")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+        SET(_java_libarch "i386")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
+        SET(_java_libarch "alpha")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+        # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
+        SET(_java_libarch "arm")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
+        # mips* machines are bi-endian mostly so processor does not tell
+        # endianess of the underlying system.
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
+        SET(_java_libarch "ppc64")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
+        SET(_java_libarch "ppc")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
+        # Both flavours can run on the same processor
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
+        SET(_java_libarch "parisc" "parisc64")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
+        # s390 binaries can run on s390x machines
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
+        SET(_java_libarch "sh")
+    ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}")
+    ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+
+    # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
+    # system is non-Linux (where the code above has not been well tested)
+    IF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+        LIST(APPEND _java_libarch "i386" "amd64" "ppc")
+    ENDIF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+
+    # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
+    # current value to a hardcoded list. Remove possible duplicates.
+    LIST(REMOVE_DUPLICATES _java_libarch)
+
+    FOREACH(_path ${ARGN})
+        IF(_path MATCHES "{libarch}")
+            FOREACH(_libarch ${_java_libarch})
+                STRING(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
+                LIST(APPEND ${_var} "${_newpath}")
+            ENDFOREACH(_libarch)
+        ELSE(_path MATCHES "{libarch}")
+            LIST(APPEND ${_var} "${_path}")
+        ENDIF(_path MATCHES "{libarch}")
+    ENDFOREACH(_path)
+ENDMACRO(java_append_library_directories)
+
+GET_FILENAME_COMPONENT(java_install_version
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
+
+SET(JAVA_AWT_LIBRARY_DIRECTORIES
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
+  )
+
+FILE(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
+
+JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+  ${_JAVA_HOME}/jre/lib/{libarch}
+  ${_JAVA_HOME}/jre/lib
+  ${_JAVA_HOME}/lib
+  ${_JAVA_HOME}
+  /usr/lib/jvm/java-6-openjdk/jre/lib
+  /usr/lib/jvm/java-6-openjdk-i386/jre/lib
+  /usr/lib/jvm/java-6-openjdk-amd64/jre/lib
+  /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-openjdk-i386/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/{libarch}
+  /usr/lib
+  /usr/local/lib
+  /usr/lib/jvm/java/lib
+  /usr/lib/java/jre/lib/{libarch}
+  /usr/local/lib/java/jre/lib/{libarch}
+  /usr/local/share/java/jre/lib/{libarch}
+  /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
+  /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
+  /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
+  /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch}       # can this one be removed according to #8821 ? Alex
+  /usr/lib/jvm/java-openjdk/jre/lib/{libarch}
+  # Debian specific paths for default JVM
+  /usr/lib/jvm/default-java/jre/lib/{libarch}
+  /usr/lib/jvm/default-java/jre/lib
+  /usr/lib/jvm/default-java/lib
+  )
+
+SET(JAVA_JVM_LIBRARY_DIRECTORIES)
+FOREACH(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
+  SET(JAVA_JVM_LIBRARY_DIRECTORIES
+    ${JAVA_JVM_LIBRARY_DIRECTORIES}
+    "${dir}"
+    "${dir}/client"
+    "${dir}/server"
+    )
+ENDFOREACH(dir)
+
+
+SET(JAVA_AWT_INCLUDE_DIRECTORIES
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
+  ${_JAVA_HOME}/include
+  /usr/lib/jvm/java-6-openjdk/include
+  /usr/lib/jvm/java-6-openjdk-amd64/include
+  /usr/lib/jvm/java-6-openjdk-i386/include
+  /usr/include 
+  /usr/local/include
+  /usr/lib/java/include
+  /usr/local/lib/java/include
+  /usr/lib/jvm/java/include
+  /usr/lib/jvm/java-6-sun/include
+  /usr/lib/jvm/java-1.5.0-sun/include
+  /usr/lib/jvm/java-6-sun-1.6.0.00/include       # can this one be removed according to #8821 ? Alex
+  /usr/lib/jvm/java-6-openjdk/include
+  /usr/local/share/java/include
+  /usr/lib/j2sdk1.4-sun/include
+  /usr/lib/j2sdk1.5-sun/include
+  /opt/sun-jdk-1.5.0.04/include
+  # Debian specific path for default JVM
+  /usr/lib/jvm/default-java/include
+  )
+
+FOREACH(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
+  GET_FILENAME_COMPONENT(jpath "${JAVA_PROG}" PATH)
+  FOREACH(JAVA_INC_PATH ../include ../java/include ../share/java/include)
+    IF(EXISTS ${jpath}/${JAVA_INC_PATH})
+      SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
+    ENDIF(EXISTS ${jpath}/${JAVA_INC_PATH})
+  ENDFOREACH(JAVA_INC_PATH)
+  FOREACH(JAVA_LIB_PATH 
+    ../lib ../jre/lib ../jre/lib/i386 
+    ../java/lib ../java/jre/lib ../java/jre/lib/i386 
+    ../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
+    IF(EXISTS ${jpath}/${JAVA_LIB_PATH})
+      SET(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
+    ENDIF(EXISTS ${jpath}/${JAVA_LIB_PATH})
+  ENDFOREACH(JAVA_LIB_PATH)
+ENDFOREACH(JAVA_PROG)
+
+IF(APPLE)
+  IF(EXISTS ~/Library/Frameworks/JavaVM.framework)
+    SET(JAVA_HAVE_FRAMEWORK 1)
+  ENDIF(EXISTS ~/Library/Frameworks/JavaVM.framework)
+  IF(EXISTS /Library/Frameworks/JavaVM.framework)
+    SET(JAVA_HAVE_FRAMEWORK 1)
+  ENDIF(EXISTS /Library/Frameworks/JavaVM.framework)
+  IF(EXISTS /System/Library/Frameworks/JavaVM.framework)
+    SET(JAVA_HAVE_FRAMEWORK 1)
+  ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework)
+
+  IF(JAVA_HAVE_FRAMEWORK)
+    IF(NOT JAVA_AWT_LIBRARY)
+      SET (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
+    ENDIF(NOT JAVA_AWT_LIBRARY)
+
+    IF(NOT JAVA_JVM_LIBRARY)
+      SET (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
+    ENDIF(NOT JAVA_JVM_LIBRARY)
+
+    IF(NOT JAVA_AWT_INCLUDE_PATH)
+      IF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
+        SET (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE)
+      ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
+    ENDIF(NOT JAVA_AWT_INCLUDE_PATH)
+
+    # If using "-framework JavaVM", prefer its headers *before* the others in
+    # JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here)
+    #
+    SET(JAVA_AWT_INCLUDE_DIRECTORIES
+      ~/Library/Frameworks/JavaVM.framework/Headers
+      /Library/Frameworks/JavaVM.framework/Headers
+      /System/Library/Frameworks/JavaVM.framework/Headers
+      ${JAVA_AWT_INCLUDE_DIRECTORIES}
+      )
+  ENDIF(JAVA_HAVE_FRAMEWORK)
+ELSE(APPLE)
+  FIND_LIBRARY(JAVA_AWT_LIBRARY jawt 
+    PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
+  )
+  FIND_LIBRARY(JAVA_JVM_LIBRARY NAMES jvm JavaVM java
+    PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES}
+  )
+ENDIF(APPLE)
+
+# add in the include path    
+FIND_PATH(JAVA_INCLUDE_PATH jni.h 
+  ${JAVA_AWT_INCLUDE_DIRECTORIES}
+)
+
+FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h 
+  ${JAVA_INCLUDE_PATH}
+  ${JAVA_INCLUDE_PATH}/win32
+  ${JAVA_INCLUDE_PATH}/linux
+  ${JAVA_INCLUDE_PATH}/freebsd
+  ${JAVA_INCLUDE_PATH}/solaris
+)
+
+FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h
+  ${JAVA_INCLUDE_PATH}
+)
+
+
+IF (APPLE)
+  # On Mac, the java headers files are broken symlinks if the Apple Developer Tools for Java are not installed
+  EXECUTE_PROCESS(COMMAND cat ${JAVA_INCLUDE_PATH}/jni.h
+                  OUTPUT_QUIET
+                  ERROR_QUIET
+                  RESULT_VARIABLE SYMLINK_CHECK_RESULT_VARIABLE)
+  IF (SYMLINK_CHECK_RESULT_VARIABLE GREATER 0)
+    SET (JAVA_INCLUDE_PATH "JAVA_INCLUDE_PATH-NOTFOUND")
+    SET (JAVA_INCLUDE_PATH2 "JAVA_INCLUDE_PATH2-NOTFOUND")
+    SET (JAVA_AWT_INCLUDE_PATH "JAVA_AWT_INCLUDE_PATH-NOTFOUND")
+  ENDIF()
+ENDIF (APPLE)
+
+
+#INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake")
+#FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI  DEFAULT_MSG  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
+#                                                    JAVA_INCLUDE_PATH  JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
+
+MARK_AS_ADVANCED(
+  JAVA_AWT_LIBRARY
+  JAVA_JVM_LIBRARY
+  JAVA_AWT_INCLUDE_PATH
+  JAVA_INCLUDE_PATH
+  JAVA_INCLUDE_PATH2
+)
+
+IF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH)
+  SET(JNI_FOUND 1)
+  SET(JNI_LIBRARIES
+    ${JAVA_AWT_LIBRARY}
+    ${JAVA_JVM_LIBRARY}
+  )
+  SET(JNI_INCLUDE_DIRS
+    ${JAVA_INCLUDE_PATH}
+    ${JAVA_INCLUDE_PATH2}
+    ${JAVA_AWT_INCLUDE_PATH}
+  )
+ELSE (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) 
+  SET(JNI_FOUND 0)
+  SET(JNI_LIBRARIES "")
+  SET(JNI_INCLUDE_DIRS "")
+ENDIF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH)

=== added directory 'cmake_modules/Windows'
=== added file 'cmake_modules/Windows/FindJNI.cmake'
--- cmake_modules/Windows/FindJNI.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/Windows/FindJNI.cmake	2014-04-30 23:07:27 +0000
@@ -0,0 +1,37 @@
+# Copyright 2010 The FLWOR Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# - Try to find the JNI libraries on Windows
+#
+# See the FindJNI.cmake module shipped with Zorba for more information.
+
+FIND_PACKAGE_WIN32_NO_PROXY (JNI JNI_FOUND)
+
+IF (JNI_FOUND)
+
+  STRING (REPLACE "/jvm.lib" "" JAVA_JVM_LIBRARY_PATH "${JAVA_JVM_LIBRARY}")
+
+  IF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+    SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+    # find the needed DLL's
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm")
+  ELSEIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server")
+    SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server")
+    # find the needed DLL's
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm")
+  ELSE (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+    MESSAGE (WARNING "Could not find the jvm.dll for the JVM library: ${JAVA_JVM_LIBRARY}. Please extend this module to find the jvm.dll somewhere in your JVM directory or make sure that jvm.dll is in the PATH.")
+  ENDIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+
+ENDIF (JNI_FOUND)

=== added directory 'include'
=== renamed directory 'include' => 'include.moved'
=== added file 'include/affectedrows.h'
--- include/affectedrows.h	1970-01-01 00:00:00 +0000
+++ include/affectedrows.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class AffectedRowsFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    AffectedRowsFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~AffectedRowsFunction()
+    {}
+
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "affected-rows"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/clearparams.h'
--- include/clearparams.h	1970-01-01 00:00:00 +0000
+++ include/clearparams.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ClearParamsFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ClearParamsFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ClearParamsFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "clear-params"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/closedataset.h'
--- include/closedataset.h	1970-01-01 00:00:00 +0000
+++ include/closedataset.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class CloseDataSetFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    CloseDataSetFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~CloseDataSetFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "close-dataset"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/closeprepared.h'
--- include/closeprepared.h	1970-01-01 00:00:00 +0000
+++ include/closeprepared.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ClosePreparedFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ClosePreparedFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ClosePreparedFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "close-prepared"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/commit.h'
--- include/commit.h	1970-01-01 00:00:00 +0000
+++ include/commit.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class CommitFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    CommitFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~CommitFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "commit"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/connect.h'
--- include/connect.h	1970-01-01 00:00:00 +0000
+++ include/connect.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ConnectFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ConnectFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ConnectFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "connect"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/connectionoptions.h'
--- include/connectionoptions.h	1970-01-01 00:00:00 +0000
+++ include/connectionoptions.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ConnectionOptionsFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+
+    ConnectionOptionsFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ConnectionOptionsFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "connection-options"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/execute.h'
--- include/execute.h	1970-01-01 00:00:00 +0000
+++ include/execute.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ExecuteFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ExecuteFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ExecuteFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "execute"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/executeprepared.h'
--- include/executeprepared.h	1970-01-01 00:00:00 +0000
+++ include/executeprepared.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ExecutePreparedFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ExecutePreparedFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ExecutePreparedFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "execute-prepared"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/executequery.h'
--- include/executequery.h	1970-01-01 00:00:00 +0000
+++ include/executequery.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ExecuteQueryFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ExecuteQueryFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ExecuteQueryFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "execute-query"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/executequerydeterm.h'
--- include/executequerydeterm.h	1970-01-01 00:00:00 +0000
+++ include/executequerydeterm.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ExecuteQueryDeterministicFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ExecuteQueryDeterministicFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ExecuteQueryDeterministicFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "execute-query-deterministic"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/executequeryprepared.h'
--- include/executequeryprepared.h	1970-01-01 00:00:00 +0000
+++ include/executequeryprepared.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ExecuteQueryPreparedFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ExecuteQueryPreparedFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ExecuteQueryPreparedFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "execute-query-prepared"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/executeupdate.h'
--- include/executeupdate.h	1970-01-01 00:00:00 +0000
+++ include/executeupdate.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ExecuteUpdateFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ExecuteUpdateFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ExecuteUpdateFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "execute-update"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/executeupdateprepared.h'
--- include/executeupdateprepared.h	1970-01-01 00:00:00 +0000
+++ include/executeupdateprepared.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ExecuteUpdatePreparedFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ExecuteUpdatePreparedFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ExecuteUpdatePreparedFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "execute-update-prepared"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/instancemap.h'
--- include/instancemap.h	1970-01-01 00:00:00 +0000
+++ include/instancemap.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+#ifndef INSTANCE_MAP
+#define INSTANCE_MAP
+
+#include <map>
+#include <string>
+#include <zorba/zorba.h>
+#include "jni.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class InstanceMap : public ExternalFunctionParameter
+{
+  private:
+    typedef std::map<String, jobject> InstanceMap_t;
+    InstanceMap_t* instanceMap;
+
+  public:
+    String id;
+
+    InstanceMap();
+    
+    bool
+    storeInstance(const String&, jobject);
+
+    jobject
+    getInstance(const String&);
+
+    bool
+    deleteInstance(const String&);
+
+    void
+    destroy() throw();
+};
+
+
+}}; // namespace zorba, jdbc
+
+#endif
\ No newline at end of file

=== added file 'include/isconnected.h'
--- include/isconnected.h	1970-01-01 00:00:00 +0000
+++ include/isconnected.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class IsConnectedFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    IsConnectedFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~IsConnectedFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "is-connected"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/javaids.h'
--- include/javaids.h	1970-01-01 00:00:00 +0000
+++ include/javaids.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+#ifndef JAVA_IDS
+#define JAVA_IDS
+
+#include "JavaVMSingleton.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class JavaDriverManager {
+public:
+  bool init();
+  jclass classID;
+  jmethodID getConnection;
+  jmethodID getConnectionWithUser;
+
+};
+class JavaConnection {
+public:
+  bool init();
+  jclass classID;
+  jmethodID commit;
+  jmethodID rollback;
+  jmethodID setAutoCommit;
+  jmethodID setReadOnly;
+  jmethodID setTransactionIsolation;
+  jmethodID getAutoCommit;
+  jmethodID isReadOnly;
+  int TRANSACTION_NONE;
+  int TRANSACTION_READ_UNCOMMITTED;
+  int TRANSACTION_READ_COMMITTED;
+  int TRANSACTION_REPEATABLE_READ;
+  int TRANSACTION_SERIALIZABLE;
+  jmethodID getTransactionIsolation;
+  jmethodID isClosed;
+  jmethodID close;
+  jmethodID createStatement;
+  jmethodID prepareStatement;
+  jmethodID getMetadata;	
+};
+class JavaStatement {
+public:
+  bool init();
+  jclass classID;
+  jmethodID getUpdateCount;
+  jmethodID getResultSet;
+  jmethodID execute;
+  jmethodID executeQuery;
+  jmethodID executeUpdate;
+};
+class JavaResultSet {
+public:
+  bool init();
+  jclass classID;
+  jmethodID last;
+  jmethodID getRow;
+  jmethodID getMetaData;
+  jmethodID beforeFirst;
+  jmethodID next;
+  jmethodID getInt;
+  jmethodID getBoolean;
+  jmethodID getDouble;
+  jmethodID getString;
+  jmethodID getBLOB;
+};
+class JavaResultSetMetadata {
+public:
+  bool init();
+  jclass classID;
+  jmethodID getColumnCount;
+  jmethodID getColumnType;
+  jmethodID getColumnName;
+  jmethodID getColumnTypeName;
+  jmethodID isAutoIncrement;
+  jmethodID isNullable;
+
+  int COLUMN_NO_NULLS;
+  int COLUMN_NULLABLE;
+  int COLUMN_NULLABLE_UNKNOWN;
+};
+class JavaPreparedStatement {
+public:
+  bool init();
+  jclass classID;
+  jmethodID clearParameters;
+  jmethodID execute;
+  jmethodID executeQuery;
+  jmethodID executeUpdate;
+  jmethodID getParameterMetaData;
+  jmethodID getUpdateCount;
+  jmethodID getResultSet;
+  jmethodID setBoolean;
+  jmethodID setNull;
+  jmethodID setDouble;
+  jmethodID setFloat;
+  jmethodID setLong;
+  jmethodID setString;
+};
+class JavaParameterMetadata {
+public:
+  bool init();
+  jclass classID;
+  jmethodID getParameterCount;
+  jmethodID getParameterTypeName;
+  jmethodID getParameterClassName;
+  jmethodID getParameterType;
+};
+class JavaBlob {
+public:
+  bool init();
+  jclass classID;
+  jmethodID getBytes;
+  jmethodID length;
+};
+class JavaDatabaseMetadata {
+public:
+  bool init();
+  jclass classID;
+  jmethodID getTables;
+};
+
+}}; // namespace zorba, jdbc
+
+#endif
\ No newline at end of file

=== added file 'include/jdbc.h'
--- include/jdbc.h	1970-01-01 00:00:00 +0000
+++ include/jdbc.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/zorba.h>
+#include <zorba/external_module.h>
+#include <zorba/util/uuid.h>
+#include "instancemap.h"
+#include "javaids.h"
+#include "JavaVMSingleton.h"
+#include "sqltypes.h"
+
+#define JDBC_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/jdbc";
+
+#define INSTANCE_MAP_CONNECTIONS "JdbcInstanceMapConnections"
+#define INSTANCE_MAP_STATEMENTS "JdbcInstanceMapStatements"
+#define INSTANCE_MAP_PREPAREDSTATEMENTS "JdbcInstanceMapPreparedStatements"
+
+class JavaException {};
+
+
+#define LOG_ACTIVE
+#ifdef LOG_ACTIVE
+#define LOG(message) std::cout << message << std::endl; std::cout.flush();
+#else
+#define LOG(message) // No logging activated
+#endif
+
+namespace zorba
+{
+namespace jdbc
+{
+
+extern JNIEnv* env;
+extern JavaDriverManager     jDriverManager;
+extern JavaConnection        jConnection;
+extern JavaStatement         jStatement;
+extern JavaResultSet         jResultSet;
+extern JavaResultSetMetadata jResultSetMetadata;
+extern JavaDatabaseMetadata  jDatabaseMetadata;
+extern JavaPreparedStatement jPreparedStatement;
+extern JavaParameterMetadata jParameterMetadata;
+extern JavaBlob              jBlob;
+extern bool isOutputJSON;
+
+#define CHECK_EXCEPTION  if ((lException = env->ExceptionOccurred())) throw JavaException();
+#define JDBC_MODULE_TRY  jthrowable lException = 0;  try   {
+#define JDBC_MODULE_CATCH   \
+  }  catch (zorba::jvm::VMOpenException&)  { \
+    JdbcModule::throwError("VM001", "Could not start the Java VM (is the classpath set?)."); \
+  }  catch (JavaException&)  { \
+    JdbcModule::throwJavaException(env, lException); \
+  }
+#define CHECK_CONNECTION \
+  if (env==NULL) { \
+    JdbcModule::throwError("SQL08003", "There is no connection to any valid source."); \
+  }
+    
+
+
+
+class JdbcModule : public ExternalModule {
+  protected:
+    class ltstr
+    {
+    public:
+      bool operator()(const String& s1, const String& s2) const
+      {
+        return s1.compare(s2) < 0;
+      }
+    };
+
+    typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t;
+    FuncMap_t lFunctions;
+
+  public:
+    JdbcModule() 
+    {};
+
+    ~JdbcModule()
+    {};
+
+    static void initGlobals(const zorba::StaticContext* aStaticContext);
+
+    virtual String getURI() const
+    { return JDBC_MODULE_NAMESPACE; }
+
+    virtual ExternalFunction* getExternalFunction(const String& localName);
+
+    virtual void destroy()
+    {
+
+      delete this;
+    }
+
+    static String 
+      getStringArg(const ExternalFunction::Arguments_t& args, int index);
+
+    static bool 
+      getOptionalStringArg(const ExternalFunction::Arguments_t& args, int index, String& aRes);
+
+    static Item 
+      getItemArg(const ExternalFunction::Arguments_t& args, int index);
+
+    static void 
+      throwJavaException(JNIEnv *env, jthrowable& lException);
+    static void
+      throwMapError(String aMap);
+    static void
+      throwError (const char *aLocalName, const char* aErrorMessage);
+    static void
+      throwError(const char *aLocalName, String aErrorMessage);
+
+    static String
+      getUUID();
+
+    static InstanceMap* 
+      getCreateInstanceMap(const zorba::DynamicContext* aDynamincContext, String mapName);
+    static jobject 
+      getObject(const zorba::DynamicContext* aDynamincContext, String aObjectUUID, String aMap);
+    static void 
+      deleteObject(const zorba::DynamicContext* aDynamincContext, String aObjectUUID, String aMap);
+
+};
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/jsonitemsequence.h'
--- include/jsonitemsequence.h	1970-01-01 00:00:00 +0000
+++ include/jsonitemsequence.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+#ifndef JSON_ITEM_SEQUENCE
+#define JSON_ITEM_SEQUENCE
+
+#include <map>
+#include <string>
+#include <jni.h>
+
+#include <zorba/zorba.h>
+#include <zorba/iterator.h>
+#include <zorba/item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+  class JSONItemSequence : public ItemSequence
+  {
+    public:
+      class JSONIterator : public Iterator
+      {
+        protected:
+          bool itOpen;
+          jobject oResultSet;
+          String* columnNames;
+          long* columnTypes;
+          long columnCount;
+          zorba::ItemFactory* itemFactory;
+          jobject oMetadata;
+
+        public:
+          JSONIterator(jobject resultSet):
+            itOpen(false), oResultSet(resultSet),columnNames(NULL),columnCount(0), oMetadata(NULL) {}
+
+          virtual ~JSONIterator() {
+          }
+
+          void
+          open();
+
+          bool
+          next(zorba::Item& aItem);
+
+          void
+          close();
+
+          bool
+          isOpen() const { return itOpen; }
+      };
+
+    protected:
+      jobject resultSet;
+
+    public:
+      JSONItemSequence(jobject resultSet)
+        : resultSet(resultSet)
+      {}
+
+      virtual ~JSONItemSequence() {}
+
+      zorba::Iterator_t 
+        getIterator() { return new JSONIterator(resultSet); }
+  };
+
+}}; // namespace zorba, jdbc
+
+#endif

=== added file 'include/metadata.h'
--- include/metadata.h	1970-01-01 00:00:00 +0000
+++ include/metadata.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class MetadataFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    MetadataFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~MetadataFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "metadata"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/parametermetadata.h'
--- include/parametermetadata.h	1970-01-01 00:00:00 +0000
+++ include/parametermetadata.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ParameterMetadataFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ParameterMetadataFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ParameterMetadataFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "parameter-metadata"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/preparestatement.h'
--- include/preparestatement.h	1970-01-01 00:00:00 +0000
+++ include/preparestatement.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class PrepareStatementFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    PrepareStatementFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~PrepareStatementFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "prepare-statement"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/resultset.h'
--- include/resultset.h	1970-01-01 00:00:00 +0000
+++ include/resultset.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class ResultSetFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    ResultSetFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~ResultSetFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "result-set"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/rollback.h'
--- include/rollback.h	1970-01-01 00:00:00 +0000
+++ include/rollback.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class RollbackFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    RollbackFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~RollbackFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "rollback"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/setboolean.h'
--- include/setboolean.h	1970-01-01 00:00:00 +0000
+++ include/setboolean.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class SetBooleanFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    SetBooleanFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~SetBooleanFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "set-boolean"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/setnull.h'
--- include/setnull.h	1970-01-01 00:00:00 +0000
+++ include/setnull.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class SetNullFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    SetNullFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~SetNullFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "set-null"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/setnumeric.h'
--- include/setnumeric.h	1970-01-01 00:00:00 +0000
+++ include/setnumeric.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class SetNumericFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    SetNumericFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~SetNumericFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "set-numeric"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/setstring.h'
--- include/setstring.h	1970-01-01 00:00:00 +0000
+++ include/setstring.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class SetStringFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    SetStringFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~SetStringFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "set-string"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}}; // namespace zorba, jdbc
+

=== added file 'include/setvalue.h'
--- include/setvalue.h	1970-01-01 00:00:00 +0000
+++ include/setvalue.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class SetValueFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    SetValueFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~SetValueFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "set-value"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+
+}} // namespace zorba, jdbc
+

=== added file 'include/sqltypes.h'
--- include/sqltypes.h	1970-01-01 00:00:00 +0000
+++ include/sqltypes.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+#ifndef SQL_TYPES
+#define SQL_TYPES
+
+#include <map>
+#include <string>
+#include <zorba/zorba.h>
+#include "jni.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class SQLTypes
+{
+
+  public:
+    static long ARRAY;
+    static long BIGINT;
+    static long BINARY;
+    static long BIT;
+    static long BLOB;
+    static long BOOLEAN;
+    static long CHAR;
+    static long CLOB;
+    static long DATALINK;
+    static long DATE;
+    static long DECIMAL;
+    static long DISTINCT;
+    static long DOUBLE;
+    static long FLOAT;
+    static long INTEGER;
+    static long JAVA_OBJECT;
+    static long LONGVARCHAR;
+    static long LONGNVARCHAR;
+    static long LONGVARBINARY;
+    static long NCHAR;
+    static long NCLOB;
+    static long _NULL;
+    static long NUMERIC;
+    static long NVARCHAR;
+    static long OTHER;
+    static long REAL;
+    static long REF;
+    static long ROWID;
+    static long SMALLINT;
+    static long SQLXML;
+    static long TIME;
+    static long TIMESTAMP;
+    static long TINYINT;
+    static long VARBINARY;
+    static long VARCHAR;
+    
+    
+    static void init();
+    static bool isInt(long lType);
+    static bool isFloat(long lType);
+    static bool isString(long lType);
+    static bool isBLOB(long lType);
+    static bool isBoolean(long lType);
+
+};
+
+
+}}; // namespace zorba, jdbc
+
+#endif
\ No newline at end of file

=== added file 'include/tables.h'
--- include/tables.h	1970-01-01 00:00:00 +0000
+++ include/tables.h	2014-04-30 23:07:27 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/item_factory.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+class TablesFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    TablesFunction(const ExternalModule* aModule);
+
+    virtual ~TablesFunction();
+
+  public:
+    virtual String getURI() const;
+
+    virtual String getLocalName() const;
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+}} // namespace zorba, jdbc

=== added directory 'setup'
=== added file 'setup/my.cnf'
--- setup/my.cnf	1970-01-01 00:00:00 +0000
+++ setup/my.cnf	2014-04-30 23:07:27 +0000
@@ -0,0 +1,90 @@
+# Example MySQL config file for small systems.
+#
+# This is for a system with little memory (<= 64M) where MySQL is only used
+# from time to time and it's important that the mysqld daemon
+# doesn't use much resources.
+#
+# MySQL programs look for option files in a set of
+# locations which depend on the deployment platform.
+# You can copy this option file to one of those
+# locations. For information about these locations, see:
+# http://dev.mysql.com/doc/mysql/en/option-files.html
+#
+# In this file, you can use all long options that a program supports.
+# If you want to know which options a program supports, run the program
+# with the "--help" option.
+
+# The following options will be passed to all MySQL clients
+[client]
+#password       = your_password
+# Non-standard port to support running on a machine with another MySQL server
+port            = 3307
+
+# Here follows entries for some specific programs
+
+# The MySQL server
+[mysqld]
+socket          = mysql.sock
+# Non-standard port to support running on a machine with another MySQL server
+port            = 3307
+skip-external-locking
+key_buffer_size = 16K
+max_allowed_packet = 1M
+table_open_cache = 4
+sort_buffer_size = 64K
+read_buffer_size = 256K
+read_rnd_buffer_size = 256K
+net_buffer_length = 2K
+thread_stack = 128K
+
+# Don't listen on a TCP/IP port at all. This can be a security enhancement,
+# if all processes that need to connect to mysqld run on the same host.
+# All interaction with mysqld must be made via Unix sockets or named pipes.
+# Note that using this option without enabling named pipes on Windows
+# (using the "enable-named-pipe" option) will render mysqld useless!
+# 
+#skip-netwrking
+server-id = 1
+
+# Uncomment the following if you want to log updates
+#log-bin=mysql-bin
+
+# binary logging format - mixed recommended
+#binlog_format=mixed
+
+# Causes updates to non-transactional engines using statement format to be
+# written directly to binary log. Before using this option make sure that
+# there are no dependencies between transactional and non-transactional
+# tables such as in the statement INSERT INTO t_myisam SELECT * FROM
+# t_innodb; otherwise, slaves may diverge from the master.
+#binlog_direct_non_transactional_updates=TRUE
+
+# Uncomment the following if you are using InnoDB tables
+innodb_data_home_dir = .
+innodb_data_file_path = ibdata1:10M:autoextend
+innodb_log_group_home_dir = innodb_log
+# You can set .._buffer_pool_size up to 50 - 80 %
+# of RAM but beware of setting memory usage too high
+innodb_buffer_pool_size = 16M
+innodb_additional_mem_pool_size = 2M
+# Set .._log_file_size to 25 % of buffer pool size
+innodb_log_file_size = 5M
+innodb_log_buffer_size = 8M
+innodb_flush_log_at_trx_commit = 1
+innodb_lock_wait_timeout = 50
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[mysql]
+no-auto-rehash
+# Remove the next comment character if you are not familiar with SQL
+#safe-updates
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+
+[mysqlhotcopy]
+interactive-timeout

=== added file 'setup/mysql-setup.sh'
--- setup/mysql-setup.sh	1970-01-01 00:00:00 +0000
+++ setup/mysql-setup.sh	2014-04-30 23:07:27 +0000
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Default location to dump stuff and create databases
+WORKDIR=`pwd`/jdbc-module-mysql
+
+# MySQL'd "datadir"
+DATADIR=${WORKDIR}/datadir
+
+# Location for the logs
+LOGDIR=${WORKDIR}/log
+
+# Filename for download
+MYSQL_PKG=mysql-5.6.12-linux-glibc2.5-x86_64
+MYSQL_TGZ=${MYSQL_PKG}.tar.gz
+
+while getopts distchw: opt
+do
+  case "$opt" in
+        w)
+            WORKDIR="$OPTARG"
+            echo "Data directory: $WORKDIR"
+            ;;
+        d)
+            echo "Download"
+            mkdir -p $WORKDIR
+            (
+            cd $WORKDIR
+            wget -c http://cdn.mysql.com/Downloads/MySQL-5.6/$MYSQL_TGZ
+            )
+            ;;
+        i)
+            echo "Install"
+            (
+            cd $WORKDIR
+            tar -xvzf $MYSQL_TGZ
+            mv $MYSQL_PKG mysql
+            sudo apt-get install libaio1
+            mkdir -p $DATADIR $LOGDIR $DATADIR/innodb_log
+            ./mysql/scripts/mysql_install_db --user=$USER --datadir=$DATADIR --basedir=./mysql --no-defaults
+            )
+            MODDIR=`dirname $0`
+            cp $MODDIR/my.cnf $DATADIR/my.cnf
+            ;;
+        s)
+            echo "Start"
+            (
+            cd $WORKDIR/mysql
+            ./bin/mysqld_safe --defaults-file=$DATADIR/my.cnf --user=$USER --pid-file=$DATADIR/mysql_rq.pid --datadir=$DATADIR --log-error=$LOGDIR/log.err &
+            )
+            ;;
+        t)
+            echo "Stop"
+            kill `cat $DATADIR/mysql_rq.pid`   
+            ;;
+        c)
+            echo "Clean everything"
+            (
+            cd $WORKDIR
+            rm -fR ./mysql
+            )
+            ;;            
+        h)
+            echo "usage: $0 [-distcvh] [-w path]"
+            echo "       -d  Download MySQL DB"
+            echo "       -i  Install"
+            echo "       -s  Start service"
+            echo "       -t  Stop service"
+            echo "       -c  Clean everything"
+            echo "       -w path  Path to store everything (default ~/jdbc-module-mysql)"
+            echo "       -h  Help"
+            exit 2
+            ;;
+        *)
+            if [ "$OPTERR" != 1 ] || [ "${optspec:0:1}" = ":" ]; then
+                echo "Non-option argument: '-${OPTARG}'"
+            fi
+
+    esac
+done

=== added directory 'src'
=== renamed directory 'src' => 'src.moved'
=== added file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ src/CMakeLists.txt	2014-04-30 23:07:27 +0000
@@ -0,0 +1,33 @@
+# Copyright 2006-2012 The FLWOR Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SET (ZORBA_WITH_JDBC ON CACHE BOOL "Compile Zorba with JDBC support" FORCE)
+INCLUDE (CMakeJavaInformation )
+MESSAGE(STATUS "Generating Java API")
+EXECUTE_PROCESS (
+  COMMAND ${JAVA_RUNTIME} -version
+  RESULT_VARIABLE JAVA_VERSION
+  OUTPUT_QUIET
+  ERROR_QUIET
+  )
+MESSAGE (STATUS "Building Zorba with JDBC support.")
+  
+INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
+INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH})
+
+DECLARE_ZORBA_MODULE (
+  URI "http://www.zorba-xquery.com/modules/jdbc";
+  VERSION 1.0
+  FILE "jdbc.xq"
+  LINK_LIBRARIES "${JAVA_JVM_LIBRARY}" ${zorba_util-jvm_module_LIBRARIES})

=== added file 'src/jdbc.xq'
--- src/jdbc.xq	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,591 @@
+xquery version "3.0";
+
+(:
+ : Copyright 2006-2012 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+
+(:~
+ : This module contains functions to connect to any JDBC datasource 
+ : using jvm-util module to handle Java interaction.
+ :
+ : @author Rodolfo Ochoa
+ : @project DB Drivers/JDBC
+ :)
+
+module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+declare namespace err = "http://www.w3.org/2005/xqt-errors";;
+declare namespace ver = "http://zorba.io/options/versioning";;
+declare namespace an = "http://zorba.io/annotations";;
+declare option ver:module-version "1.0";
+
+(:~
+ : This variable represents the NOT-SUPPORTED level for Isolation Levels in $options for 2.2 connect function.
+ :)
+declare variable $jdbc:NOT-SUPPORTED    := "NOT-SUPPORTED";
+(:~
+ : This variable represents the READ-COMMITTED level for Isolation Levels in $options for 2.2 connect function.
+ :)
+declare variable $jdbc:READ-COMMITTED   := "READ-COMMITTED";
+(:~
+ : This variable represents the READ-UNCOMMITTED level for Isolation Levels in $options for 2.2 connect function.
+ :)
+declare variable $jdbc:READ-UNCOMMITTED := "READ-UNCOMMITTED";
+(:~
+ : This variable represents the REPEATABLE-READ level for Isolation Levels in $options for 2.2 connect function.
+ :)
+declare variable $jdbc:REPEATABLE-READ  := "REPEATABLE-READ";
+(:~
+ : This variable represents the SERIALIZABLE level for Isolation Levels in $options for 2.2 connect function.
+ :)
+declare variable $jdbc:SERIALIZABLE     := "SERIALIZABLE";
+
+(:
+ : 2 CONNECTION HANDLING
+ :)
+
+(:~
+ : Opens a connection to a database.
+ : Returns a URI identifying the connection that has been opened. The implementing code determines from the $connection-config either explicitly (interpreting the driver attribute) or implicitly (using the type attribute) which driver it has to load.
+ :
+ : @param $connection-config json object that has the host and user informations.
+ : @option "url" URL of the server, this option must be specified and should be declared according to JDBC specification.
+ : @option "user" username for the server, this is optional.
+ : @option "password" password for the server, this is optional.
+ :
+ : @error SQL28000 Authentication failed.
+ : @error SQL08001 Connection error.
+ : @error SQL40003 Isolation level not supported.
+ : @error SQL001 Descriptive error, see attached message.
+ :
+ : @return Return an identifier that represents the connection to the server.
+ :
+ : Connection coonfiguration example:
+ : { "url" : "jdbc:mysql://localhost/", 
+ :   "user" : "root",
+ :   "password" : "" }
+ : 
+ :)
+declare %an:sequential function jdbc:connect(
+                                     $connection-config as object() ) as xs:anyURI external;
+
+(:~
+ : Opens a connection to a database with specified options.
+ : Returns a URI identifying the connection that has been opened. The implementing code determines from the $connection-config either explicitly (interpreting the driver attribute) or implicitly (using the type attribute) which driver it has to load.
+ :
+ : @param $connection-config json object that has the host and user informations.
+ : @option "url" URL of the server, this option must be specified and should be declared according to JDBC specification.
+ : @option "user" username for the server, this option is optional.
+ : @option "password" password for the server, this option is optional.
+ : @param $options json object that specifies the connection options.
+ : @option "autocommit" The created connection will have autocommit turned on if the value the attribute is set to "true".
+ : @option "readonly" The created connection will be readonly if the value of the attribute is set to "true".
+ : @option "isolation-level" The created connection will have the specified transaction isolation level, 
+ : the following string typed in-scope variables represent the different transaction isolation levels 
+ : that this attribute can be set to:
+ : - $jsql:READ-COMMITTED
+ : - $jsql:READ-UNCOMMITTED
+ : - $jsql:REPEATABLE-READ
+ : - $jsql:SERIALIZABLE
+ : if no isolation level is provided by the user the connection will be created with the default 
+ : isolation level of the database.
+ :
+ :
+ : @error SQL28000 Authentication failed.
+ : @error SQL08001 Connection error.
+ : @error SQL40003 Isolation level not supported.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an identifier that represents the connection to the server.
+ :
+ : Connection options example:
+ : { "autocommit" : false, 
+ :   "readonly"? : true,
+ :   "isolation-level"? : $jdbc:READ-COMMITTED }
+ : 
+ :)
+declare %an:sequential function jdbc:connect(
+                                     $connection-config as object(), 
+                                     $options as object()?) as xs:anyURI external;
+
+(:~
+ : Verify if a connection is still active.
+ :
+ : @param $connection-id The identifier to the connection to be verify.
+ :
+ : @error SQL08003 Connection doesn't exist
+ : @error SQL001 Descriptive error, see error in attached message
+ :
+ : @return Returns true if connected.
+ :)
+declare function jdbc:is-connected(
+                                     $connection-id as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Returns a set with options for a specified connection.
+ :
+ : @param $connection-id The identifier to the connection to be verify.
+ :
+ : @error SQL08003 Connection doesn't exist
+ : @error SQL08000 Connection is closed
+ : @error SQL001 Descriptive error, see error in attached message
+ :
+ : @return Returns and object with the connection options.
+ : The returned options are equal to the options specified in function jdbc:connect. 
+ : Consequently, the options are specified as follows:
+ :    { "autocommit" : xs:boolean,
+ :      "readonly" : xs:boolean,
+ :      "isolation-level" : xs:string }
+ :
+ :)
+declare function jdbc:connection-options(
+                                      $connection-id as xs:anyURI) as object() external;
+
+(:
+ : 3 TRANSACTIONS
+ :)
+
+(:~
+ : Commit current transaction from an active connection.
+ :
+ : @param $connection-id The identifier to the connection to be commited.
+ : 
+ : @error SQL08003 Connection doesn't exist
+ : @error SQL08000 Connection is closed
+ : @error SQL001 Descriptive error, see error in attached message
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:commit(
+                                      $connection-id as xs:anyURI) as empty-sequence() external;
+
+(:~
+ : Rollback the current transaction of a connection.
+ :
+ : @param $connection-id The identifier to the connection to be rollbacked.
+ :
+ : @error SQL08003 Connection doesn't exist
+ : @error SQL08000 Connection is closed
+ : @error SQL001 Descriptive error, see error in attached message
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:rollback(
+                                      $connection-id as xs:anyURI) as empty-sequence() external;
+
+
+(:
+ : 4 SIMPLE STATEMENTS
+ :)
+
+(:~
+ : Executes any kind of SQL statement. 
+ :
+ : @param $connection-id The identifier to an active connection.
+ : @param $sql The query string to be executed.
+ : 
+ : @error SQL08003 Connection doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an identifier that represents a DataSet.
+ :)
+declare %an:sequential function jdbc:execute( 
+                                      $connection-id as xs:anyURI,
+                                      $sql as xs:string ) as xs:anyURI external;
+
+(:~
+ : Executes non-updating SQL statements.
+ :
+ : @param $connection-id The identifier to an active connection.
+ : @param $sql The query string to be executed.
+ : 
+ : @error SQL08003 Connection doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL005 The statement is Updating type.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an object with the result data rows from the query provided,
+ :  the data rows are defined as follows:
+ :   { column:value* }*
+ :  Every row is represented by an object of column-value representation of the returned SQL result.
+ :
+ :)
+declare function jdbc:execute-query( 
+                                      $connection-id as xs:anyURI, 
+                                      $sql as xs:string) as object()* external;
+
+(:~
+ : Executes updating SQL statements.
+ :
+ : @param $connection-id The identifier to an active connection.
+ : @param $sql The query string to be executed.
+ : 
+ : @error SQL08003 Connection doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL005 The statement is Read-only type.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Returns an xs:integer with the number of affected rows.
+ :)
+declare function jdbc:execute-update(
+                                      $connection-id as xs:anyURI,
+                                      $sql as xs:string) as xs:integer external;
+
+
+(:
+ :  5 PREPARED STATEMENTS
+ :)
+
+(:~
+ :  Creates a prepared statement for multiple executions with diferent values.
+ :
+ : @param $connection-id The identifier to an active connection.
+ : @param $sql The query string to be executed.
+ : 
+ : @error SQL08003 Connection doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an identifier that represents the prepared statement.
+ :
+ : Example:
+ : jsql:prepare-statement($connection, "SELECT * FROM users WHERE id=? AND age>?")
+ :)
+declare %an:sequential function jdbc:prepare-statement(
+                                      $connection-id as xs:anyURI,
+                                      $sql as xs:string) as xs:anyURI external;
+
+(:~
+ : Set the value of the designated parameter with the given value, this function will assign only numeric values.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : @param $parameter-index The index from the parameter to be set.
+ : @param $value The value to be set.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL007 Parameter casting error.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:set-numeric(
+                                      $prepared-statement as xs:anyURI, 
+                                      $parameter-index as xs:decimal, 
+                                      $value as xs:anyAtomicType) as empty-sequence() external;
+
+(:~
+ : Set the value of the designated parameter with the given value, this function will assign only string values.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : @param $parameter-index The index from the parameter to be set.
+ : @param $value The value to be set.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL007 Parameter casting error.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:set-string(
+                                      $prepared-statement as xs:anyURI,
+                                      $parameter-index as xs:integer,
+                                      $value as xs:string) as empty-sequence() external;
+
+(:~
+ : Set the value of the designated parameter with the given value, this function will assign only boolean values.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : @param $parameter-index The index from the parameter to be set.
+ : @param $value The value to be set.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL007 Parameter casting error.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:set-boolean(
+                                      $prepared-statement as xs:anyURI, 
+                                      $parameter-index as xs:integer,
+                                      $value as xs:boolean) as empty-sequence() external;
+
+(:~
+ : Set the value of the designated parameter with the given value, this function will assign only null values if possible.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : @param $parameter-index The index from the parameter to be set.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL007 Parameter casting error.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:set-null(
+                                      $prepared-statement as xs:anyURI,
+                                      $parameter-index as xs:integer) as empty-sequence() external;
+
+(:~
+ : Set the value of the designated parameter with the given value, 
+ : this function will assign any value you send 
+ : and it will try to cast to the correct type.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : @param $parameter-index The index from the parameter to be set.
+ : @param $value The value to be set.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL007 Parameter casting error.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:set-value(
+                                      $prepared-statement as xs:anyURI, 
+                                      $parameter-index as xs:decimal, 
+                                      $value as xs:anyAtomicType) as empty-sequence() external;
+
+(:~
+ : Clears the current parameter values immediately.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:clear-params(
+                                      $prepared-statement as xs:anyURI) as empty-sequence() external;
+
+(:~
+ : Retrieves the number, types and properties of the prepared statement parameters.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns the parameters metadata associated with a prepared statement. 
+ : In other words, it returns information about the column name associated with the parameter, the type, etc.
+ : The metadata node returned by this function is defined as follows:
+ :   {
+ :     columns: [{
+ :       "name": xs:string,
+ :       "type": xs:string
+ :       }]
+ :   }
+ : @option "name" The name of the column.
+ : @option "type" The SQL type of the column.
+ :)
+declare function jdbc:parameter-metadata(
+                                      $prepared-statement as xs:anyURI) as object() external;
+
+(:~
+ : Executes SQL statements prepared with 5.1 jsql:prepare-statement with values set
+ : and returns an identifier to a Dataset.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an identifier that represents a DataSet.
+ :)
+declare %an:sequential function jdbc:execute-prepared(
+                                      $prepared-statement as xs:anyURI) as xs:anyURI external;
+
+(:~
+ : Executes a non-updating SQL statement prepared with 5.1 jsql:prepare-statement.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL005 The prepared statement is an updating query.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an object with the result data rows from the query processed with the parameter values provided,
+ :  the data rows are defined as follows:
+ :   { column:value* }*
+ :  Every row is represented by an object of column-value representation of the returned SQL result.
+ :)
+declare function jdbc:execute-query-prepared(
+                                      $prepared-statement as xs:anyURI) as object()* external;
+
+(:~
+ : Executes an updating SQL statement prepared with 5.1 jsql:prepare-statement.
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL006 The prepared statement is a non-updating query.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Returns an xs:integer with the number of affected rows.
+ :)
+declare function jdbc:execute-update-prepared(
+                                      $prepared-statement as xs:anyURI) as xs:integer external;
+
+(:~
+ : Closes and frees from memory any prepared SQL statement created with jdbc:prepare-statement
+ :
+ : @param $prepared-statement The identifier to a prepared statement.
+ : 
+ : @error SQL003 Prepared statement doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:close-prepared(
+                                      $prepared-statement as xs:anyURI) as empty-sequence() external;
+
+
+(:
+ :  6 DATASETS
+ :)
+
+(:~
+ : This function returns a sequence of objects representing the rows of data from a non-updating query.
+ :
+ : @param $dataset-id The identifier to a DataSet.
+ : 
+ : @error SQL008 DataSet doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an object with the result data rows from the DataSet provided,
+ :  the data rows are defined as follows:
+ :   { column:value* }*
+ :  Every row is represented by an object of column-value representation of the returned SQL result.
+ :)
+declare function jdbc:result-set(
+                                      $dataset-id as xs:anyURI) as object()* external;
+
+(:~
+ : Return the metadata of the result of a particular DataSet.
+ :
+ : @param $dataset-id The identifier to a DataSet.
+ : 
+ : @error SQL008 DataSet doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns the metadata associated with an executed DataSet. More in detail, it returns information about column names, types, and whether a column can contain a null value.
+ : The metadata information can only be returned for DataSets that have been executed explicitly using the jsql:execute function.
+ : 
+ : The metadata node returned by this function is defined as follows:
+ : {
+ :   "columns": [ {
+ :       "name": xs:string,
+ :       "type": xs:string,
+ :       "autoincrement"? = xs:boolean,
+ :       "nillable"? = xs:boolean } * ]
+ : }
+ : @option "name" The name of the column.
+ : @option "type" The SQL type of the column.
+ : @option "autoincrement" is true if this column is automatically maintained.
+ : @option "nillable" If the colums can contain NULL values this attribute will be set to true.
+ :
+ : If the query is an updating query, then the result object will return the number of affected rows like:
+ : { "affectedrows": xs:integer }
+ :)
+declare function jdbc:metadata(
+                                      $dataset-id as xs:anyURI) as object() external;
+
+(:~
+ : Return the number of affected rows of a particular DataSet.
+ :
+ : @param $dataset-id The identifier to a DataSet.
+ : 
+ : @error SQL008 DataSet doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Returns an xs:integer with the number of affected rows.
+ :)
+declare function jdbc:affected-rows(
+                                      $dataset-id as xs:anyURI) as xs:integer external;
+
+(:~
+ : Closes and free resources from a particular DataSet.
+ :
+ : @param $dataset-id The identifier to a DataSet.
+ : 
+ : @error SQL008 DataSet doesn't exist.
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return This function returns an empty-sequence()
+ :)
+declare %an:sequential function jdbc:close-dataset(
+                                      $dataset-id as xs:anyURI) as empty-sequence() external;
+
+(:~
+ : Return the list of tables from a connection
+ :
+ : @param $connection-id The identifier to a connection.
+ : @param $catalog A filter of the catalog name of the tables.
+ :             Send empty-sequence for all tables.
+ : @param $schema A filter of the schema name of the tables.
+ :             Send empty-sequence for all tables.
+ : @param $table A filter of the name of the tables.
+ :             Send empty-sequence for all tables.
+ : 
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an object with the result data rows from the query provided,
+ :  the data rows are defined as follows:
+ :   { column:value* }*
+ :  Every row is represented by an object of column-value representation of the returned SQL result.
+ :
+ :)
+declare %an:sequential function jdbc:tables(
+                                      $connection-id as xs:anyURI, 
+                                      $catalog as xs:string?, 
+                                      $schema as xs:string?, 
+                                      $table as xs:string?) as object()* external;
+
+(:~
+ :
+ : Return the list of tables from a connection
+ :
+ : @param $connection-id The identifier to a connection.
+ :
+ : @error SQL08000 Connection is closed.
+ : @error SQL001 Descriptive error, see error in attached message.
+ :
+ : @return Return an object with the result data rows from the query provided,
+ :  the data rows are defined as follows:
+ :   { column:value* }*
+ :  Every row is represented by an object of column-value representation of the returned SQL result.
+ :)
+declare %an:sequential function jdbc:tables(
+                                      $connection-id as xs:anyURI) as object()*
+{
+	jdbc:tables($connection-id, (), (), ())
+};

=== added directory 'src/jdbc.xq.src'
=== added directory 'src/jdbc.xq.src/connection'
=== added file 'src/jdbc.xq.src/connection/connect.cpp'
--- src/jdbc.xq.src/connection/connect.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/connection/connect.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "connect.h"
+#include "jdbc.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ConnectFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  JdbcModule::initGlobals(aStaticContext);
+  Item result;
+  JDBC_MODULE_TRY
+    jstring url(NULL), username(NULL), password(NULL);
+    Item item = JdbcModule::getItemArg(args, 0);
+    bool hasUsername=false;
+    if (item.isJSONItem()) 
+    {
+      Iterator_t lKeys = item.getObjectKeys();
+      lKeys->open();
+      Item lKey;
+      while (lKeys->next(lKey))
+      {
+        zorba::String keystring = lKey.getStringValue();
+        zorba::String value = item.getObjectValue(keystring).getStringValue();
+        if (keystring=="url") {
+          url =  env->NewStringUTF(value.c_str());
+          CHECK_EXCEPTION
+        } else if (keystring=="user") {
+          username =  env->NewStringUTF(value.c_str());
+          CHECK_EXCEPTION
+          hasUsername = true;
+        } else if (keystring=="password") {
+          password =  env->NewStringUTF(value.c_str());
+          CHECK_EXCEPTION
+        } else if (keystring.compare("type")) {
+        } else if (keystring.compare("driver")) {
+        }
+      }
+      lKeys->close();
+    }
+
+    jobject oConnection;
+    if (hasUsername) {
+      oConnection = env->CallStaticObjectMethod(jDriverManager.classID, jDriverManager.getConnectionWithUser, url, username, password);
+      CHECK_EXCEPTION
+    } else {
+      oConnection = env->CallStaticObjectMethod(jDriverManager.classID, jDriverManager.getConnection, url);
+      CHECK_EXCEPTION
+    }
+
+    item = JdbcModule::getItemArg(args, 1);
+    if ((!item.isNull()) && (item.isJSONItem()))
+    {
+      Iterator_t lKeys = item.getObjectKeys();
+      lKeys->open();
+      Item lKey;
+      while (lKeys->next(lKey))
+      {
+        zorba::String keystring = lKey.getStringValue();
+        if (keystring=="autocommit") {
+          jboolean value = JNI_FALSE;
+          if (item.getObjectValue(keystring).getBooleanValue()) {
+            value = JNI_TRUE;
+          }
+          env->CallVoidMethod(oConnection, jConnection.setAutoCommit, value);
+          CHECK_EXCEPTION
+        } else if (keystring=="readonly") {
+          jboolean value = JNI_FALSE;
+          if (item.getObjectValue(keystring).getBooleanValue()) {
+            value = JNI_TRUE;
+          }
+          env->CallVoidMethod(oConnection, jConnection.setReadOnly, value);
+          CHECK_EXCEPTION
+        } else if (keystring=="isolation-level") {
+          jint isolationLevel = (int) item.getObjectValue(keystring).getLongValue();
+          env->CallVoidMethod(oConnection, jConnection.setTransactionIsolation, isolationLevel);
+          CHECK_EXCEPTION
+        }
+      }
+      lKeys->close();
+    }
+
+    InstanceMap* lInstanceMap = JdbcModule::getCreateInstanceMap(aDynamincContext, INSTANCE_MAP_CONNECTIONS);
+    String lStrUUID = JdbcModule::getUUID();
+    lInstanceMap->storeInstance(lStrUUID, oConnection);
+
+    result = theFactory->createAnyURI(lStrUUID);
+  JDBC_MODULE_CATCH
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/connection/connectionoptions.cpp'
--- src/jdbc.xq.src/connection/connectionoptions.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/connection/connectionoptions.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "connectionoptions.h"
+#include "jdbc.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ConnectionOptionsFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStrUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lStrUUID, INSTANCE_MAP_CONNECTIONS);
+
+    std::vector<std::pair<Item, Item> > resultVector;
+
+    jboolean isAutocommit = env->CallBooleanMethod(oConnection, jConnection.getAutoCommit);
+    resultVector.push_back(std::pair<Item, Item>(theFactory->createString("autocommit"), theFactory->createBoolean(isAutocommit==JNI_TRUE)));
+    CHECK_EXCEPTION
+    jboolean isReadonly = env->CallBooleanMethod(oConnection, jConnection.isReadOnly);
+    resultVector.push_back(std::pair<Item, Item>(theFactory->createString("readonly"), theFactory->createBoolean(isReadonly==JNI_TRUE)));
+    CHECK_EXCEPTION
+
+    int isolationLevel = env->CallIntMethod(oConnection, jConnection.getTransactionIsolation);
+    CHECK_EXCEPTION
+    String isolLevel;
+    if (isolationLevel==jConnection.TRANSACTION_NONE) {
+      isolLevel = "NOT-SUPPORTED";
+    } else if (isolationLevel==jConnection.TRANSACTION_READ_UNCOMMITTED) {
+      isolLevel = "READ-UNCOMMITTED";
+    } else if (isolationLevel==jConnection.TRANSACTION_READ_COMMITTED) {
+      isolLevel = "READ-COMMITTED";
+    } else if (isolationLevel==jConnection.TRANSACTION_REPEATABLE_READ) {
+      isolLevel = "REPEATABLE-READ";
+    } else if (isolationLevel==jConnection.TRANSACTION_SERIALIZABLE) {
+      isolLevel = "SERIALIZABLE";
+    }
+    resultVector.push_back(std::pair<Item, Item>(theFactory->createString("isolation-level"), theFactory->createString(isolLevel)));
+    result = theFactory->createJSONObject(resultVector);
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/connection/isconnected.cpp'
--- src/jdbc.xq.src/connection/isconnected.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/connection/isconnected.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "isconnected.h"
+#include "jdbc.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+IsConnectedFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION  
+  jboolean isClosed = JNI_FALSE;
+  JDBC_MODULE_TRY
+    String lConnectionUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lConnectionUUID, INSTANCE_MAP_CONNECTIONS);
+
+    isClosed = env->CallBooleanMethod(oConnection, jConnection.isClosed);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(theFactory->createBoolean(isClosed==JNI_FALSE)));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/connection/tables.cpp'
--- src/jdbc.xq.src/connection/tables.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/connection/tables.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "tables.h"
+#include "jdbc.h"
+#include "jsonitemsequence.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+TablesFunction::TablesFunction(const ExternalModule* aModule)
+  : theModule(aModule),
+    theFactory(Zorba::getInstance(0)->getItemFactory()),
+    theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+{}
+
+TablesFunction::~TablesFunction()
+{}
+
+String
+TablesFunction::getURI() const
+{
+  return theModule->getURI();
+}
+
+String
+TablesFunction::getLocalName() const
+{
+  return "tables";
+}
+
+ItemSequence_t
+TablesFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  jobject result=NULL;
+
+  JDBC_MODULE_TRY
+
+    String lStrUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lStrUUID, INSTANCE_MAP_CONNECTIONS);
+
+    jobject oDatabaseMetadata = env->CallObjectMethod(oConnection, jConnection.getMetadata);
+
+    String sTemp;
+    jstring jCatalog = NULL;
+    if (JdbcModule::getOptionalStringArg(args, 1, sTemp))
+    {
+      jCatalog = env->NewStringUTF(sTemp.c_str());
+    }
+    jstring jSchema = NULL;
+    if (JdbcModule::getOptionalStringArg(args, 2, sTemp))
+    {
+      jSchema = env->NewStringUTF(sTemp.c_str());
+    }
+    jstring jTable = NULL;
+    if (JdbcModule::getOptionalStringArg(args, 3, sTemp))
+    {
+      jTable = env->NewStringUTF(sTemp.c_str());
+    }
+    jobjectArray jTypes = env->NewObjectArray(1, env->FindClass("java/lang/String"), env->NewStringUTF("TABLE"));
+    
+    result = env->CallObjectMethod(oDatabaseMetadata, jDatabaseMetadata.getTables, jCatalog, jSchema, jTable, jTypes);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new JSONItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added directory 'src/jdbc.xq.src/datasets'
=== added file 'src/jdbc.xq.src/datasets/affectedrows.cpp'
--- src/jdbc.xq.src/datasets/affectedrows.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/datasets/affectedrows.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "affectedrows.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+AffectedRowsFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    zorba::ItemFactory* itemFactory = Zorba::getInstance(0)->getItemFactory();
+
+    jobject oStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_STATEMENTS);
+
+    int rowsAffected = env->CallIntMethod(oStatement, jStatement.getUpdateCount);
+    CHECK_EXCEPTION
+
+    if (rowsAffected==-1) { // NON UPDATE QUERY
+      jobject oResultSet = env->CallObjectMethod(oStatement, jStatement.getResultSet);
+      CHECK_EXCEPTION
+
+      jboolean hasRows = env->CallBooleanMethod(oResultSet, jResultSet.last);
+      CHECK_EXCEPTION
+
+      if (hasRows==JNI_TRUE) {
+        rowsAffected = env->CallBooleanMethod(oResultSet, jResultSet.getRow);
+        CHECK_EXCEPTION
+      } else {
+        rowsAffected=0;
+      }
+    }
+    result = itemFactory->createInteger(rowsAffected);
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/datasets/closedataset.cpp'
--- src/jdbc.xq.src/datasets/closedataset.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/datasets/closedataset.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "closedataset.h"
+#include "jdbc.h"
+#include "jsonitemsequence.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+CloseDataSetFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+  JdbcModule::deleteObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_STATEMENTS);
+
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/datasets/metadata.cpp'
--- src/jdbc.xq.src/datasets/metadata.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/datasets/metadata.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "metadata.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+MetadataFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_STATEMENTS);
+
+    zorba::ItemFactory* itemFactory = Zorba::getInstance(0)->getItemFactory();
+
+    int rowsAffected = env->CallIntMethod(oStatement, jStatement.getUpdateCount);
+    CHECK_EXCEPTION
+
+    std::vector<std::pair<zorba::Item, zorba::Item> > vResult;
+    if (rowsAffected==-1) { // NON UPDATE QUERY
+      jobject oResultSet = env->CallObjectMethod(oStatement, jStatement.getResultSet);
+      CHECK_EXCEPTION
+
+      jobject oMetadata = env->CallObjectMethod(oResultSet, jResultSet.getMetaData);
+      CHECK_EXCEPTION
+
+      int columns = env->CallIntMethod(oMetadata, jResultSetMetadata.getColumnCount);
+      CHECK_EXCEPTION
+
+      std::vector<zorba::Item> elements;
+
+      for (int i=1; i<=columns; i++) {
+          std::vector<std::pair<zorba::Item, zorba::Item> > column;
+
+          jstring oName = (jstring) env->CallObjectMethod(oMetadata, jResultSetMetadata.getColumnName, i);
+          CHECK_EXCEPTION
+          const char * cName = env->GetStringUTFChars(oName, 0);
+          String sName(cName);
+          CHECK_EXCEPTION
+          zorba::Item iName = itemFactory->createString(sName);
+          std::pair<zorba::Item, zorba::Item> pName(itemFactory->createString("name"), iName);
+          column.push_back(pName);
+          env->ReleaseStringUTFChars(oName, cName);
+          CHECK_EXCEPTION 
+
+          jstring oType = (jstring) env->CallObjectMethod(oMetadata, jResultSetMetadata.getColumnTypeName, i);
+          CHECK_EXCEPTION
+          const char * cType = env->GetStringUTFChars(oType, 0);
+          CHECK_EXCEPTION 
+          String  sType(cType);
+          zorba::Item iType = itemFactory->createString(sType);
+          std::pair<zorba::Item, zorba::Item> pType(itemFactory->createString("type"), iType);
+          column.push_back(pType);
+          elements.push_back(itemFactory->createJSONObject(column));
+          env->ReleaseStringUTFChars(oType, cType);
+          CHECK_EXCEPTION 
+
+          bool isAutoIncrement = (JNI_TRUE == env->CallBooleanMethod(oMetadata, jResultSetMetadata.isAutoIncrement, i));
+          CHECK_EXCEPTION
+          std::pair<zorba::Item, zorba::Item> pAutoIncrement(itemFactory->createString("autoincrement"), itemFactory->createBoolean(isAutoIncrement));
+          column.push_back(pAutoIncrement);
+          elements.push_back(itemFactory->createJSONObject(column));
+          CHECK_EXCEPTION 
+
+          jint isNullable = env->CallIntMethod(oMetadata, jResultSetMetadata.isNullable, i);
+          CHECK_EXCEPTION
+          if (isNullable != jResultSetMetadata.COLUMN_NULLABLE_UNKNOWN) {
+            std::pair<zorba::Item, zorba::Item> pAutoIncrement(itemFactory->createString("nullable"), itemFactory->createBoolean(isNullable==jResultSetMetadata.COLUMN_NULLABLE));
+            column.push_back(pAutoIncrement);
+            elements.push_back(itemFactory->createJSONObject(column));
+            CHECK_EXCEPTION 
+          }
+      }
+      std::pair<zorba::Item, zorba::Item> allColumns(itemFactory->createString("columns"), itemFactory->createJSONArray(elements));
+      vResult.push_back(allColumns);
+    } else { // UPDATE QUERY
+      std::pair<zorba::Item, zorba::Item> allColumns(itemFactory->createString("affectedrows"), itemFactory->createInteger(rowsAffected));
+      vResult.push_back(allColumns);
+    }
+    result = itemFactory->createJSONObject(vResult);
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/datasets/resultset.cpp'
--- src/jdbc.xq.src/datasets/resultset.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/datasets/resultset.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "resultset.h"
+#include "jdbc.h"
+#include "jsonitemsequence.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ResultSetFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  jobject result=NULL;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_STATEMENTS);
+
+    int iUpdateCount = env->CallIntMethod(oPreparedStatement, jPreparedStatement.getUpdateCount);
+    CHECK_EXCEPTION
+    if (iUpdateCount != -1) {
+       JdbcModule::throwError("SQL005", "Query must be a non-updating query.");
+    }
+
+    result = env->CallObjectMethod(oPreparedStatement, jPreparedStatement.getResultSet);
+    CHECK_EXCEPTION
+    
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new JSONItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/instancemap.cpp'
--- src/jdbc.xq.src/instancemap.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/instancemap.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "instancemap.h"
+#include "jdbc.h"
+#include "jni.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+InstanceMap::InstanceMap()
+{   
+  InstanceMap::instanceMap = new InstanceMap_t();
+}
+
+bool
+InstanceMap::storeInstance(const String& aKeyName, jobject aInstance)
+{
+  std::pair<InstanceMap_t::iterator, bool> ret;
+  ret = instanceMap->insert(std::pair<String, jobject>(aKeyName, aInstance));
+  return ret.second;
+}
+
+jobject
+InstanceMap::getInstance(const String& aKeyName)
+{
+  InstanceMap::InstanceMap_t::iterator lIter = instanceMap->find(aKeyName);
+  
+  if (lIter == instanceMap->end())
+    return NULL;
+  
+  jobject lInstance = lIter->second;
+
+  return lInstance;
+}
+
+bool
+InstanceMap::deleteInstance(const String& aKeyName)
+{
+  InstanceMap::InstanceMap_t::iterator lIter = instanceMap->find(aKeyName);
+
+  if (lIter == instanceMap->end())
+    return false;
+
+  JDBC_MODULE_TRY
+    if (id == INSTANCE_MAP_CONNECTIONS) {
+      env->CallVoidMethod(lIter->second, jConnection.close);
+      CHECK_EXCEPTION
+    }
+    env->DeleteLocalRef(lIter->second);
+    CHECK_EXCEPTION
+  JDBC_MODULE_CATCH
+
+  instanceMap->erase(lIter);
+
+  return true;
+}
+
+void
+InstanceMap::destroy() throw()
+{
+  if (instanceMap)
+  {
+    for (InstanceMap_t::const_iterator lIter = instanceMap->begin();
+         lIter != instanceMap->end(); ++lIter)
+    {
+    JDBC_MODULE_TRY
+      if (id == INSTANCE_MAP_CONNECTIONS) {
+        env->CallVoidMethod(lIter->second, jConnection.close);
+        CHECK_EXCEPTION
+      }
+      env->DeleteLocalRef(lIter->second);
+      CHECK_EXCEPTION
+    JDBC_MODULE_CATCH
+    }
+    instanceMap->clear();
+    delete instanceMap;
+  }
+  delete this;
+};
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/javaids.cpp'
--- src/jdbc.xq.src/javaids.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/javaids.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "javaids.h"
+#include "jdbc.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+  bool JavaDriverManager::init() {
+    classID = env->FindClass("java/sql/DriverManager");
+    getConnection = env->GetStaticMethodID(classID, "getConnection", "(Ljava/lang/String;)Ljava/sql/Connection;");
+    getConnectionWithUser = env->GetStaticMethodID(classID, "getConnection", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection;");
+    return true;
+  }
+  bool JavaConnection::init() {
+    classID = env->FindClass("java/sql/Connection");
+    commit = env->GetMethodID(classID, "commit", "()V");
+    rollback = env->GetMethodID(classID, "rollback", "()V");
+    setAutoCommit = env->GetMethodID(classID, "setAutoCommit", "(Z)V");
+    setReadOnly = env->GetMethodID(classID, "setReadOnly", "(Z)V");
+    setTransactionIsolation = env->GetMethodID(classID, "setTransactionIsolation", "(I)V");
+    getAutoCommit = env->GetMethodID(classID, "getAutoCommit", "()Z");
+    isReadOnly = env->GetMethodID(classID, "isReadOnly", "()Z");
+    getTransactionIsolation =  env->GetMethodID(classID, "getTransactionIsolation", "()I");
+    isClosed = env->GetMethodID(classID, "isClosed", "()Z");
+    close = env->GetMethodID(classID, "close", "()V");
+    createStatement = env->GetMethodID(classID, "createStatement", "()Ljava/sql/Statement;");
+    prepareStatement = env->GetMethodID(classID, "prepareStatement", "(Ljava/lang/String;)Ljava/sql/PreparedStatement;");
+    getMetadata = env->GetMethodID(classID, "getMetaData", "()Ljava/sql/DatabaseMetaData;");
+
+    TRANSACTION_NONE = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "TRANSACTION_NONE", "I"));
+    TRANSACTION_READ_UNCOMMITTED = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "TRANSACTION_READ_UNCOMMITTED", "I"));
+    TRANSACTION_READ_COMMITTED = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "TRANSACTION_READ_COMMITTED", "I"));
+    TRANSACTION_REPEATABLE_READ = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "TRANSACTION_REPEATABLE_READ", "I"));
+    TRANSACTION_SERIALIZABLE = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "TRANSACTION_SERIALIZABLE", "I"));
+    return true;
+  }
+  bool JavaStatement::init() {
+    classID = env->FindClass("java/sql/Statement");
+    getUpdateCount = env->GetMethodID(classID, "getUpdateCount", "()I");
+    getResultSet = env->GetMethodID(classID, "getResultSet", "()Ljava/sql/ResultSet;");
+    execute = env->GetMethodID(classID, "execute", "(Ljava/lang/String;)Z");
+    executeQuery = env->GetMethodID(classID, "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;");
+    executeUpdate = env->GetMethodID(classID, "executeUpdate", "(Ljava/lang/String;)I");
+    return true;
+  }
+  bool JavaResultSet::init() {
+    classID = env->FindClass("java/sql/ResultSet");
+    last = env->GetMethodID(classID, "last", "()Z");
+    getRow = env->GetMethodID(classID, "getRow", "()I");
+    getMetaData = env->GetMethodID(classID, "getMetaData", "()Ljava/sql/ResultSetMetaData;");
+    beforeFirst = env->GetMethodID(classID, "beforeFirst", "()V");
+    next = env->GetMethodID(classID, "next", "()Z");
+    getInt = env->GetMethodID(classID, "getInt", "(I)I");
+    getBoolean = env->GetMethodID(classID, "getBoolean", "(I)Z");
+    getDouble = env->GetMethodID(classID, "getDouble", "(I)D");
+    getString = env->GetMethodID(classID, "getString", "(I)Ljava/lang/String;");
+    getBLOB = env->GetMethodID(classID, "getBlob", "(I)Ljava/sql/Blob;");
+    return true;
+  }
+  bool JavaResultSetMetadata::init() {
+    classID = env->FindClass("java/sql/ResultSetMetaData");
+    getColumnCount = env->GetMethodID(classID, "getColumnCount", "()I");
+    getColumnType = env->GetMethodID(classID, "getColumnType", "(I)I");
+    getColumnName = env->GetMethodID(classID, "getColumnName", "(I)Ljava/lang/String;");
+    getColumnTypeName = env->GetMethodID(classID, "getColumnTypeName", "(I)Ljava/lang/String;");
+    isAutoIncrement = env->GetMethodID(classID, "isAutoIncrement", "(I)Z");
+    isNullable = env->GetMethodID(classID, "isNullable", "(I)I");
+
+    COLUMN_NO_NULLS = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "columnNoNulls", "I"));
+    COLUMN_NULLABLE = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "columnNullable", "I"));
+    COLUMN_NULLABLE_UNKNOWN = env->GetStaticIntField(classID, env->GetStaticFieldID(classID, "columnNullableUnknown", "I"));
+    return true;
+  }
+  bool JavaDatabaseMetadata::init() {
+    classID = env->FindClass("java/sql/DatabaseMetaData");
+    getTables = env->GetMethodID(classID, "getTables", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;");
+    return true;
+  }
+  bool JavaPreparedStatement::init() {
+    classID = env->FindClass("java/sql/PreparedStatement");
+    clearParameters = env->GetMethodID(classID, "clearParameters", "()V");
+    execute = env->GetMethodID(classID, "execute", "()Z");
+    executeQuery = env->GetMethodID(classID, "executeQuery", "()Ljava/sql/ResultSet;");
+    executeUpdate = env->GetMethodID(classID, "executeUpdate", "()I");
+    getParameterMetaData = env->GetMethodID(classID, "getParameterMetaData", "()Ljava/sql/ParameterMetaData;");
+    getUpdateCount = env->GetMethodID(classID, "getUpdateCount", "()I");
+    getResultSet = env->GetMethodID(classID, "getResultSet", "()Ljava/sql/ResultSet;");
+    setBoolean = env->GetMethodID(classID, "setBoolean", "(IZ)V");
+    setNull = env->GetMethodID(classID, "setNull", "(II)V");
+    setDouble = env->GetMethodID(classID, "setDouble", "(ID)V");
+    setFloat = env->GetMethodID(classID, "setFloat", "(IF)V");
+    setLong = env->GetMethodID(classID, "setLong", "(IJ)V");
+    setString = env->GetMethodID(classID, "setString", "(ILjava/lang/String;)V");
+    return true;
+  }
+  bool JavaParameterMetadata::init() {
+    classID = env->FindClass("java/sql/ParameterMetaData");
+    getParameterCount = env->GetMethodID(classID, "getParameterCount", "()I");
+    getParameterTypeName = env->GetMethodID(classID, "getParameterTypeName",  "(I)Ljava/lang/String;");
+    getParameterClassName = env->GetMethodID(classID, "getParameterClassName", "(I)Ljava/lang/String;");
+    getParameterType = env->GetMethodID(classID, "getParameterType", "(I)I");
+    return true;
+  }
+  bool JavaBlob::init() {
+    classID = env->FindClass("java/sql/Blob");
+    getBytes = env->GetMethodID(classID, "getBytes", "(JI)[B");
+    length = env->GetMethodID(classID, "length", "()J");
+    return true;
+  }
+
+}}; // namespace zorba, jdbc
+

=== added file 'src/jdbc.xq.src/jdbc.cpp'
--- src/jdbc.xq.src/jdbc.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/jdbc.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,376 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zorba/diagnostic_list.h>
+#include <zorba/empty_sequence.h>
+#include <zorba/external_module.h>
+#include <zorba/function.h>
+#include <zorba/item_factory.h>
+#include <zorba/serializer.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/user_exception.h>
+#include <zorba/util/base64_util.h>
+#include <zorba/vector_item_sequence.h>
+#include <zorba/zorba.h>
+
+#include "jdbc.h"
+
+#include "connect.h"
+#include "connectionoptions.h"
+#include "isconnected.h"
+#include "commit.h"
+#include "rollback.h"
+#include "execute.h"
+#include "executequery.h"
+#include "executequerydeterm.h"
+#include "executeupdate.h"
+#include "clearparams.h"
+#include "executeprepared.h"
+#include "executequeryprepared.h"
+#include "executeupdateprepared.h"
+#include "closeprepared.h"
+#include "parametermetadata.h"
+#include "preparestatement.h"
+#include "setboolean.h"
+#include "setnull.h"
+#include "setnumeric.h"
+#include "setstring.h"
+#include "setvalue.h"
+#include "affectedrows.h"
+#include "metadata.h"
+#include "resultset.h"
+#include "closedataset.h"
+#include "tables.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+
+JNIEnv*               env;
+JavaDriverManager     jDriverManager;
+JavaConnection        jConnection;
+JavaStatement         jStatement;
+JavaResultSet         jResultSet;
+JavaResultSetMetadata jResultSetMetadata;
+JavaDatabaseMetadata  jDatabaseMetadata;
+JavaPreparedStatement jPreparedStatement;
+JavaParameterMetadata jParameterMetadata;
+JavaBlob              jBlob;
+bool isOutputJSON = true;
+
+zorba::ExternalFunction* 
+JdbcModule::getExternalFunction(const zorba::String& localName)
+{
+  FuncMap_t::iterator lIte = lFunctions.find(localName);
+
+  ExternalFunction*& lFunc = lFunctions[localName];
+
+  if (lIte == lFunctions.end())
+  {
+    // 2 CONNECTION HANDLING
+    if (localName == "connect")
+    {
+      lFunc = new ConnectFunction(this);
+    }
+    else if (localName == "is-connected")
+    {
+      lFunc = new IsConnectedFunction(this);
+    }
+    else if (localName == "connection-options")
+    {
+      lFunc = new ConnectionOptionsFunction(this);
+    }
+    // 3 TRANSACTIONS
+    else if (localName == "commit")
+    {
+      lFunc = new CommitFunction(this);
+    }
+    else if (localName == "rollback")
+    {
+      lFunc = new RollbackFunction(this);
+    }
+    // 4 SIMPLE STATEMENTS
+    else if (localName == "execute")
+    {
+      lFunc = new ExecuteFunction(this);
+    }
+    else if (localName == "execute-query")
+    {
+      lFunc = new ExecuteQueryFunction(this);
+    }
+    else if (localName == "execute-update")
+    {
+      lFunc = new ExecuteUpdateFunction(this);
+    }
+    // 5 PREPARED STATEMENTS
+    else if (localName == "prepare-statement")
+    {
+      lFunc = new PrepareStatementFunction(this);
+    }
+    else if (localName == "set-numeric")
+    {
+      lFunc = new SetNumericFunction(this);
+    }
+    else if (localName == "set-string")
+    {
+      lFunc = new SetStringFunction(this);
+    }
+    else if (localName == "set-boolean")
+    {
+      lFunc = new SetBooleanFunction(this);
+    }
+    else if (localName == "set-null")
+    {
+      lFunc = new SetNullFunction(this);
+    }
+    else if (localName == "set-value")
+    {
+      lFunc = new SetValueFunction(this);
+    }
+    else if (localName == "clear-params")
+    {
+      lFunc = new ClearParamsFunction(this);
+    }
+    else if (localName == "parameter-metadata")
+    {
+      lFunc = new ParameterMetadataFunction(this);
+    }
+    else if (localName == "execute-prepared")
+    {
+      lFunc = new ExecutePreparedFunction(this);
+    }
+    else if (localName == "execute-query-prepared")
+    {
+      lFunc = new ExecuteQueryPreparedFunction(this);
+    }
+    else if (localName == "execute-update-prepared")
+    {
+      lFunc = new ExecuteUpdatePreparedFunction(this);
+    }
+    else if (localName == "close-prepared")
+    {
+      lFunc = new ClosePreparedFunction(this);
+    }
+    // 6 DATASETS
+    else if (localName == "result-set")
+    {
+      lFunc = new ResultSetFunction(this);
+    }
+    else if (localName == "metadata")
+    {
+      lFunc = new MetadataFunction(this);
+    }
+    else if (localName == "affected-rows")
+    {
+      lFunc = new AffectedRowsFunction(this);
+    }
+    else if (localName == "close-dataset")
+    {
+      lFunc = new CloseDataSetFunction(this);
+    }
+    else if (localName == "tables")
+    {
+      lFunc = new TablesFunction(this);
+    }
+  }
+  return lFunc;
+}
+
+void
+JdbcModule::throwMapError(String aMap)
+{
+      if (aMap == INSTANCE_MAP_CONNECTIONS) {
+        throwError("SQL08003", "Connection does not exist.");
+      } else if (aMap == INSTANCE_MAP_STATEMENTS) {
+        throwError("SQL003", "Statement does not exist.");
+      } else if (aMap == INSTANCE_MAP_PREPAREDSTATEMENTS) {
+        throwError("SQL008", "Prepared statement does not exist.");
+      }
+}
+
+void
+JdbcModule::throwError(const char *aLocalName, const char* aErrorMessage)
+{
+  String errDescription(aErrorMessage);
+  JdbcModule::throwError (aLocalName, errDescription);
+}
+
+void
+JdbcModule::throwError(const char *aLocalName, String aErrorMessage)
+{
+  String errNS(JDBC_MODULE_NAMESPACE);
+  String errName(aLocalName);
+  Item errQName = Zorba::getInstance(0)->getItemFactory()->createQName(errNS, errName);
+  throw USER_EXCEPTION(errQName, aErrorMessage);
+}
+
+void
+JdbcModule::throwJavaException(JNIEnv *env, jthrowable& lException)
+{
+  jclass stringWriterClass = env->FindClass("java/io/StringWriter");
+  jclass printWriterClass = env->FindClass("java/io/PrintWriter");
+  jclass throwableClass = env->FindClass("java/lang/Throwable");
+  jobject stringWriter = env->NewObject(
+      stringWriterClass,
+      env->GetMethodID(stringWriterClass, "<init>", "()V"));
+
+  jobject printWriter = env->NewObject(
+      printWriterClass,
+      env->GetMethodID(printWriterClass, "<init>", "(Ljava/io/Writer;)V"),
+      stringWriter);
+
+  env->CallObjectMethod(lException,
+      env->GetMethodID(throwableClass, "printStackTrace",
+          "(Ljava/io/PrintWriter;)V"),
+      printWriter);
+
+  //env->CallObjectMethod(printWriter, env->GetMethodID(printWriterClass, "flush", "()V"));
+  jmethodID toStringMethod =
+    env->GetMethodID(stringWriterClass, "toString", "()Ljava/lang/String;");
+  jobject errorMessageObj = env->CallObjectMethod(
+      stringWriter, toStringMethod);
+  jstring errorMessage = (jstring) errorMessageObj;
+  const char *errMsg = env->GetStringUTFChars(errorMessage, 0);
+  std::stringstream s;
+  s << "A Java Exception was thrown:" << std::endl << errMsg;
+  env->ReleaseStringUTFChars(errorMessage, errMsg);
+  std::string err("");
+  err += s.str();
+  env->ExceptionClear();
+  JdbcModule::throwError("JAVA-EXCEPTION", err);
+}
+
+String
+JdbcModule::getStringArg(const ExternalFunction::Arguments_t& args, int index) {
+  String result;  
+  Iterator_t lIter = args[index]->getIterator();
+  lIter->open();
+  Item item;
+  if( lIter->next(item) )
+  {
+    result = item.getStringValue();
+  }
+  lIter->close();
+  return result;
+}
+
+bool
+JdbcModule::getOptionalStringArg(const ExternalFunction::Arguments_t& args, int index, String& aRes) {
+  Iterator_t lIter = args[index]->getIterator();
+  lIter->open();
+  Item item;
+  if( lIter->next(item) )
+  {
+    aRes = item.getStringValue();
+    lIter->close();
+    return true;
+  }
+  lIter->close();
+  return false;
+}
+
+Item
+JdbcModule::getItemArg(const ExternalFunction::Arguments_t& args, int index) {
+  Item item;
+  if (index < (int)args.size()) {
+    Iterator_t lIter = args[index]->getIterator();
+    lIter->open();
+    lIter->next(item);
+    lIter->close();
+  }
+  return item;
+}
+
+String
+JdbcModule::getUUID() {
+  uuid lUUID;
+  uuid::create(&lUUID);
+  std::stringstream lStream;
+  lStream << lUUID;
+  return lStream.str();
+}
+
+InstanceMap* 
+  JdbcModule::getCreateInstanceMap(const zorba::DynamicContext* aDynamincContext, String mapName) {
+
+  InstanceMap* result;
+  DynamicContext* lDctx = const_cast<DynamicContext*>(aDynamincContext);
+  if (!(result = dynamic_cast<InstanceMap*>(lDctx->getExternalFunctionParameter(mapName))))
+  {
+    result = new InstanceMap();
+    result->id = mapName;
+    lDctx->addExternalFunctionParameter(mapName, result);
+  }
+  return result;
+}
+
+jobject 
+  JdbcModule::getObject(const zorba::DynamicContext* aDynamincContext, String aObjectUUID, String aMap) {
+    InstanceMap* lInstanceMap = getCreateInstanceMap(aDynamincContext, aMap);
+    if (lInstanceMap==NULL)
+      throwMapError(aMap);
+    jobject oResult = lInstanceMap->getInstance(aObjectUUID);
+    if(oResult==NULL)
+      throwMapError(aMap);
+    return oResult;
+}
+
+void 
+  JdbcModule::deleteObject(const zorba::DynamicContext* aDynamincContext, String aObjectUUID, String aMap) {
+    InstanceMap* lInstanceMap = getCreateInstanceMap(aDynamincContext, aMap);
+    if (lInstanceMap==NULL)
+      throwMapError(aMap);
+    jobject oResult = lInstanceMap->getInstance(aObjectUUID);
+    if(oResult==NULL)
+      throwMapError(aMap);
+    lInstanceMap->deleteInstance(aObjectUUID);
+}
+
+void JdbcModule::initGlobals(const zorba::StaticContext* aStaticContext) {
+  if (env!=NULL) 
+    return;
+  JDBC_MODULE_TRY
+    env = zorba::jvm::JavaVMSingleton::getInstance(aStaticContext)->getEnv();
+    CHECK_EXCEPTION
+    jDriverManager.init();
+    jConnection.init();
+    jStatement.init();
+    jResultSet.init();
+    jResultSetMetadata.init();
+    jDatabaseMetadata.init();
+    jPreparedStatement.init();
+    jParameterMetadata.init();
+    jBlob.init();
+    SQLTypes::init();
+  JDBC_MODULE_CATCH
+}
+
+
+}}; // namespace zorba, jdbc
+
+#ifdef WIN32
+#  define DLL_EXPORT __declspec(dllexport)
+#else
+#  define DLL_EXPORT __attribute__ ((visibility("default")))
+#endif
+
+extern "C" DLL_EXPORT zorba::ExternalModule* createModule()
+{
+  return new zorba::jdbc::JdbcModule();
+}
+/* vim:set et sw=2 ts=2: */

=== added file 'src/jdbc.xq.src/jsonitemsequence.cpp'
--- src/jdbc.xq.src/jsonitemsequence.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/jsonitemsequence.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jsonitemsequence.h"
+#include "sqltypes.h"
+#include "jdbc.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+  void JSONItemSequence::JSONIterator::open(){
+    if(oResultSet == NULL)
+      return;
+
+    JDBC_MODULE_TRY
+      itemFactory = Zorba::getInstance(0)->getItemFactory();
+
+      oMetadata = env->CallObjectMethod(oResultSet, jResultSet.getMetaData);
+      CHECK_EXCEPTION
+      columnCount = env->CallIntMethod(oMetadata, jResultSetMetadata.getColumnCount);
+      CHECK_EXCEPTION
+
+      // Getting column names and types
+      columnNames = new String[columnCount];
+      columnTypes = new long[columnCount];
+      for(int i=0; i<columnCount; i++){
+        jstring oName = (jstring) env->CallObjectMethod(oMetadata, jResultSetMetadata.getColumnName, i+1);
+        CHECK_EXCEPTION
+        const char * cName = env->GetStringUTFChars(oName, 0);
+        CHECK_EXCEPTION
+        columnNames[i] = String(cName);
+        env->ReleaseStringUTFChars(oName, cName);
+        CHECK_EXCEPTION 
+        columnTypes[i] = env->CallIntMethod(oMetadata, jResultSetMetadata.getColumnType, i+1);
+
+        if (columnTypes[i] == SQLTypes::BINARY)
+        {
+          jstring oType = (jstring) env->CallObjectMethod(oMetadata, jResultSetMetadata.getColumnTypeName, i+1);
+          CHECK_EXCEPTION
+          const char * cType = env->GetStringUTFChars(oType, 0);
+          CHECK_EXCEPTION
+          if (strcmp(cType, "timestamp") == 0) columnTypes[i] = SQLTypes::TIMESTAMP;
+        }
+
+        CHECK_EXCEPTION
+      }
+    JDBC_MODULE_CATCH
+    itOpen=true;
+  }
+
+  bool JSONItemSequence::JSONIterator::next(zorba::Item& aItem){
+    bool result = false;
+    if(!itOpen)
+      return result;
+
+    JDBC_MODULE_TRY
+      jboolean hasNext = env->CallBooleanMethod(oResultSet, jResultSet.next);
+      CHECK_EXCEPTION
+      if (hasNext == JNI_FALSE)
+        return result;
+
+      std::vector<std::pair<zorba::Item, zorba::Item> > elements;
+      for(int i=0; i<columnCount; i++){
+        zorba::Item aKey = itemFactory->createString(columnNames[i]);
+        zorba::Item aValue;
+        if (SQLTypes::isInt(columnTypes[i])) {
+          int value = env->CallIntMethod(oResultSet, jResultSet.getInt, i+1);
+          CHECK_EXCEPTION
+          aValue = itemFactory->createInteger(value);
+        } else if (SQLTypes::isFloat(columnTypes[i])) {
+          double value = env->CallDoubleMethod(oResultSet, jResultSet.getDouble, i+1);
+          CHECK_EXCEPTION
+          aValue = itemFactory->createDouble(value);
+        } else if (SQLTypes::isBoolean(columnTypes[i])) {
+            bool value = env->CallBooleanMethod(oResultSet, jResultSet.getBoolean, i+1);
+          CHECK_EXCEPTION
+          aValue = itemFactory->createBoolean(value);
+        } else if (SQLTypes::isString(columnTypes[i])) {
+          jstring sValue = (jstring) env->CallObjectMethod(oResultSet, jResultSet.getString, i+1);
+          CHECK_EXCEPTION
+          if (sValue!=NULL) {
+            const char *value = env->GetStringUTFChars(sValue, 0);
+            CHECK_EXCEPTION
+            aValue = itemFactory->createString(String(value));
+            env->ReleaseStringUTFChars(sValue, value);
+          } else {
+            aValue = itemFactory->createJSONNull();
+          }
+        } else if (SQLTypes::isBLOB(columnTypes[i])) {
+          jobject oBlob = env->CallObjectMethod(oResultSet, jResultSet.getBLOB, i+1);
+          CHECK_EXCEPTION
+          if (oBlob!=NULL) {
+            jint length = env->CallIntMethod(oBlob, jBlob.length);
+            CHECK_EXCEPTION
+            jbyteArray bytes  = (jbyteArray) env->CallObjectMethod(oBlob, jBlob.getBytes, 1, length);
+            CHECK_EXCEPTION
+            const char* byteString = reinterpret_cast<const char*>(env->GetByteArrayElements(bytes, 0));
+            aValue = itemFactory->createBase64Binary(byteString, length, false);
+          } else {
+            aValue = itemFactory->createJSONNull();
+          } 
+        } else if (columnTypes[i]==SQLTypes::_NULL) {
+            aValue = itemFactory->createJSONNull();
+        }
+        elements.push_back(std::pair<zorba::Item, zorba::Item>(aKey, aValue));
+      }
+      aItem = itemFactory->createJSONObject(elements);
+      elements.clear();
+      result = true;
+    JDBC_MODULE_CATCH
+    return result;
+  }
+
+  void JSONItemSequence::JSONIterator::close(){
+    delete[] columnNames;
+    delete[] columnTypes;
+    itOpen = false;
+    columnCount = 0;
+  }
+
+}}; // namespace zorba, jdbc

=== added directory 'src/jdbc.xq.src/prepared'
=== added file 'src/jdbc.xq.src/prepared/clearparams.cpp'
--- src/jdbc.xq.src/prepared/clearparams.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/clearparams.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "clearparams.h"
+#include "jdbc.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ClearParamsFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    env->CallVoidMethod(oPreparedStatement, jPreparedStatement.clearParameters);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/closeprepared.cpp'
--- src/jdbc.xq.src/prepared/closeprepared.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/closeprepared.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "closeprepared.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ClosePreparedFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  
+  String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+  JdbcModule::deleteObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/executeprepared.cpp'
--- src/jdbc.xq.src/prepared/executeprepared.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/executeprepared.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "executeprepared.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ExecutePreparedFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+  
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    env->CallBooleanMethod(oPreparedStatement, jPreparedStatement.execute);
+    CHECK_EXCEPTION
+
+    InstanceMap* lInstanceMap = JdbcModule::getCreateInstanceMap(aDynamincContext, INSTANCE_MAP_STATEMENTS);
+    String resultUUID = JdbcModule::getUUID();
+    lInstanceMap->storeInstance(resultUUID, oPreparedStatement);
+
+    result = theFactory->createAnyURI(resultUUID);
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/executequeryprepared.cpp'
--- src/jdbc.xq.src/prepared/executequeryprepared.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/executequeryprepared.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "executequeryprepared.h"
+#include "jdbc.h"
+#include "jsonitemsequence.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ExecuteQueryPreparedFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  jobject result=NULL;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    result = env->CallObjectMethod(oPreparedStatement, jPreparedStatement.executeQuery);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new JSONItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/executeupdateprepared.cpp'
--- src/jdbc.xq.src/prepared/executeupdateprepared.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/executeupdateprepared.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "executeupdateprepared.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ExecuteUpdatePreparedFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    int rowCount = env->CallIntMethod(oPreparedStatement, jPreparedStatement.executeUpdate);
+    CHECK_EXCEPTION
+
+    result = theFactory->createInteger(rowCount);
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/parametermetadata.cpp'
--- src/jdbc.xq.src/prepared/parametermetadata.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/parametermetadata.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "parametermetadata.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ParameterMetadataFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    jobject oParameterMetaData = env->CallObjectMethod(oPreparedStatement, jPreparedStatement.getParameterMetaData);
+    CHECK_EXCEPTION
+
+    int columns = env->CallIntMethod(oParameterMetaData, jParameterMetadata.getParameterCount);
+    CHECK_EXCEPTION
+
+    zorba::ItemFactory* itemFactory = Zorba::getInstance(0)->getItemFactory();
+    std::vector<zorba::Item> elements;
+
+    for (int i=1; i<=columns; i++) {
+        std::vector<std::pair<zorba::Item, zorba::Item> > column;
+
+        jstring oName = (jstring) env->CallObjectMethod(oParameterMetaData, jParameterMetadata.getParameterClassName, i);
+        CHECK_EXCEPTION
+        const char * cName = env->GetStringUTFChars(oName, 0);
+        CHECK_EXCEPTION
+        String sName(cName);
+        zorba::Item iName = itemFactory->createString(sName);
+        std::pair<zorba::Item, zorba::Item> pName(itemFactory->createString("name"), iName);
+        column.push_back(pName);
+        env->ReleaseStringUTFChars(oName, cName);
+        CHECK_EXCEPTION 
+
+        jstring oType = (jstring) env->CallObjectMethod(oParameterMetaData, jParameterMetadata.getParameterTypeName, i);
+        CHECK_EXCEPTION
+        const char * cType = env->GetStringUTFChars(oType, 0);
+        CHECK_EXCEPTION 
+        String  sType(cType);
+        zorba::Item iType = itemFactory->createString(sType);
+        std::pair<zorba::Item, zorba::Item> pType(itemFactory->createString("type"), iType);
+        column.push_back(pType);
+        elements.push_back(itemFactory->createJSONObject(column));
+        env->ReleaseStringUTFChars(oType, cType);
+        CHECK_EXCEPTION 
+    }
+    std::pair<zorba::Item, zorba::Item> allColumns(itemFactory->createString("columns"), itemFactory->createJSONArray(elements));
+    std::vector<std::pair<zorba::Item, zorba::Item> > vResult;
+    vResult.push_back(allColumns);
+    result = itemFactory->createJSONObject(vResult);
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/preparestatement.cpp'
--- src/jdbc.xq.src/prepared/preparestatement.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/preparestatement.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "preparestatement.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+PrepareStatementFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  Item result;
+  
+  JDBC_MODULE_TRY
+    String lConnectionUUID = JdbcModule::getStringArg(args, 0);
+    String lQuery = JdbcModule::getStringArg(args, 1);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lConnectionUUID, INSTANCE_MAP_CONNECTIONS);
+
+    jstring query =  env->NewStringUTF(lQuery.c_str());
+    jobject oPrepared = env->CallObjectMethod(oConnection, jConnection.prepareStatement, query);
+    CHECK_EXCEPTION
+
+    InstanceMap* lInstanceMap = JdbcModule::getCreateInstanceMap(aDynamincContext, INSTANCE_MAP_PREPAREDSTATEMENTS);
+    String resultUUID = JdbcModule::getUUID();
+    lInstanceMap->storeInstance(resultUUID, oPrepared);
+
+    result = theFactory->createAnyURI(resultUUID);
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/setboolean.cpp'
--- src/jdbc.xq.src/prepared/setboolean.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/setboolean.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "setboolean.h"
+#include "jdbc.h"
+
+using namespace zorba::store;
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+SetBooleanFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    long index = (long)JdbcModule::getItemArg(args, 1).getLongValue();
+    Item value = JdbcModule::getItemArg(args, 2);
+    int type = value.getTypeCode();
+
+    if (type == XS_BOOLEAN) {
+      jboolean val = JNI_FALSE;
+      if (value.getBooleanValue())
+        val = JNI_TRUE;
+      env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setBoolean, index, val);
+    } else {
+      JdbcModule::throwError("SQL004", "Error setting boolean value.");
+    }
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/setnull.cpp'
--- src/jdbc.xq.src/prepared/setnull.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/setnull.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "setnull.h"
+#include "jdbc.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+SetNullFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    jobject oParameterMetadata = env->CallObjectMethod(oPreparedStatement, jPreparedStatement.getParameterMetaData);
+    CHECK_EXCEPTION
+
+    long index = (long)JdbcModule::getItemArg(args, 1).getLongValue();
+    int parameterType = env->CallIntMethod(oParameterMetadata, jParameterMetadata.getParameterType, index);
+    CHECK_EXCEPTION
+
+    env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setNull, index, parameterType);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/setnumeric.cpp'
--- src/jdbc.xq.src/prepared/setnumeric.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/setnumeric.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "setnumeric.h"
+#include "jdbc.h"
+
+using namespace zorba::store;
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+SetNumericFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    long index = (long)JdbcModule::getItemArg(args, 1).getLongValue();
+    Item value = JdbcModule::getItemArg(args, 2);
+    int type = value.getTypeCode();
+
+    switch (type) {
+      case XS_DOUBLE:
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setDouble, index, value.getDoubleValue());
+      break;
+      case XS_FLOAT:
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setFloat, index, value.getDoubleValue());
+      break;
+      case XS_INTEGER:
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setLong, index, value.getLongValue());
+      break;
+      case XS_DECIMAL:
+        double dVal;
+        sscanf(value.getStringValue().c_str(), "%lf", &dVal);
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setDouble, index,  dVal);
+      break;
+      default:
+        JdbcModule::throwError("SQL004", "Error setting numeric value.");
+      break;
+    }
+    CHECK_EXCEPTION
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/setstring.cpp'
--- src/jdbc.xq.src/prepared/setstring.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/setstring.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "setstring.h"
+#include "jdbc.h"
+
+using namespace zorba::store;
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+  SetStringFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    long index = (long)JdbcModule::getItemArg(args, 1).getLongValue();
+    Item value = JdbcModule::getItemArg(args, 2);
+    int type = value.getTypeCode();
+
+    if (type == XS_STRING) {
+      jstring val =  env->NewStringUTF(value.getStringValue().c_str());
+      env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setString, index, val);
+    } else {
+      JdbcModule::throwError("SQL004", "Error setting string value.");
+    }
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/prepared/setvalue.cpp'
--- src/jdbc.xq.src/prepared/setvalue.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/prepared/setvalue.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "setvalue.h"
+#include "jdbc.h"
+
+using namespace zorba::store;
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+SetValueFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lStatementUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oPreparedStatement = JdbcModule::getObject(aDynamincContext, lStatementUUID, INSTANCE_MAP_PREPAREDSTATEMENTS);
+
+    long index = (long)JdbcModule::getItemArg(args, 1).getLongValue();
+    Item value = JdbcModule::getItemArg(args, 2);
+    int type = value.getTypeCode();
+
+    switch (type) {
+      case XS_DOUBLE:
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setDouble, index, value.getDoubleValue());
+      break;
+      case XS_FLOAT:
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setFloat, index, value.getDoubleValue());
+        break;
+      case XS_INTEGER:
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setLong, index, value.getLongValue());
+        break;
+      case XS_DECIMAL: {
+        double dVal;
+        sscanf(value.getStringValue().c_str(), "%lf", &dVal);
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setDouble, index,  dVal);
+        break;
+      }
+      case XS_BOOLEAN: {
+        jboolean boolval = JNI_FALSE;
+        if (value.getBooleanValue())
+          boolval = JNI_TRUE;
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setBoolean, index, boolval);
+        break;
+      }
+      case JS_NULL: {
+        jobject oParameterMetadata = env->CallObjectMethod(oPreparedStatement, jPreparedStatement.getParameterMetaData);
+        CHECK_EXCEPTION;
+        int parameterType = env->CallIntMethod(oParameterMetadata, jParameterMetadata.getParameterType, index);
+        CHECK_EXCEPTION;
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setNull, index, parameterType);
+        CHECK_EXCEPTION;
+        break;
+      }
+      default: { // STRING
+        jstring stringval =  env->NewStringUTF(value.getStringValue().c_str());
+        env->CallVoidMethod(oPreparedStatement, jPreparedStatement.setString, index, stringval);
+        break;
+      }
+    }
+    CHECK_EXCEPTION
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}} // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/sqltypes.cpp'
--- src/jdbc.xq.src/sqltypes.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/sqltypes.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sqltypes.h"
+#include "jdbc.h"
+#include "jni.h"
+
+
+namespace zorba
+{
+namespace jdbc
+{
+long SQLTypes::ARRAY;
+long SQLTypes::BIGINT;
+long SQLTypes::BINARY;
+long SQLTypes::BIT;
+long SQLTypes::BLOB;
+long SQLTypes::BOOLEAN;
+long SQLTypes::CHAR;
+long SQLTypes::CLOB;
+long SQLTypes::DATALINK;
+long SQLTypes::DATE;
+long SQLTypes::DECIMAL;
+long SQLTypes::DISTINCT;
+long SQLTypes::DOUBLE;
+long SQLTypes::FLOAT;
+long SQLTypes::INTEGER;
+long SQLTypes::JAVA_OBJECT;
+long SQLTypes::LONGVARCHAR;
+long SQLTypes::LONGNVARCHAR;
+long SQLTypes::LONGVARBINARY;
+long SQLTypes::NCHAR;
+long SQLTypes::NCLOB;
+long SQLTypes::_NULL;
+long SQLTypes::NUMERIC;
+long SQLTypes::NVARCHAR;
+long SQLTypes::OTHER;
+long SQLTypes::REAL;
+long SQLTypes::REF;
+long SQLTypes::ROWID;
+long SQLTypes::SMALLINT;
+long SQLTypes::SQLXML;
+long SQLTypes::TIME;
+long SQLTypes::TIMESTAMP;
+long SQLTypes::TINYINT;
+long SQLTypes::VARBINARY;
+long SQLTypes::VARCHAR;
+
+void SQLTypes::init() {
+  static bool TypesLoaded=false;
+  if (TypesLoaded) 
+    return;
+  TypesLoaded = true;
+    jclass cTypes = env->FindClass("java/sql/Types");
+    ARRAY    = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "ARRAY", "I"));
+    BIGINT   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "BIGINT", "I"));
+    BINARY   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "BINARY", "I"));
+    BIT      = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "BIT", "I"));
+    BLOB     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "BLOB", "I"));
+    BOOLEAN  = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "BOOLEAN", "I"));
+    CHAR     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "CHAR", "I"));
+    CLOB     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "CLOB", "I"));
+    DATALINK = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "DATALINK", "I"));
+    DATE     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "DATE", "I"));
+    DECIMAL  = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "DECIMAL", "I"));
+    DOUBLE   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "DOUBLE", "I"));
+    FLOAT    = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "FLOAT", "I"));
+    INTEGER  = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "INTEGER", "I"));
+    JAVA_OBJECT   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "JAVA_OBJECT", "I"));
+    LONGVARCHAR   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "LONGVARCHAR", "I"));
+    LONGNVARCHAR  = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "LONGNVARCHAR", "I"));
+    LONGVARBINARY = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "LONGVARBINARY", "I"));
+    NCHAR     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "NCHAR", "I"));
+    NCLOB     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "NCLOB", "I"));
+    _NULL     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "NULL", "I"));
+    NUMERIC   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "NUMERIC", "I"));
+    NVARCHAR  = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "NVARCHAR", "I"));
+    OTHER     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "OTHER", "I"));
+    REAL      = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "REAL", "I"));
+    REF       = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "REF", "I"));
+    ROWID     = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "ROWID", "I"));
+    SMALLINT  = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "SMALLINT", "I"));
+    SQLXML    = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "SQLXML", "I"));
+    TIME      = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "TIME", "I"));
+    TIMESTAMP = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "TIMESTAMP", "I"));
+    TINYINT   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "TINYINT", "I"));
+    VARBINARY = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "VARBINARY", "I"));
+    VARCHAR   = env->GetStaticIntField(cTypes, env->GetStaticFieldID(cTypes, "VARCHAR", "I"));
+}
+
+bool SQLTypes::isBLOB(long lType) {
+  return (
+          (lType == BINARY) || (lType == BLOB) || (lType==LONGVARBINARY) || (lType==VARBINARY) ||
+          (lType == ARRAY) || (lType == DATALINK) || (lType==JAVA_OBJECT) || (lType==OTHER) ||
+          (lType == REF)
+         );
+}
+
+bool SQLTypes::isString(long lType) {
+  return (
+          (lType == CHAR) || (lType == CLOB) || (lType == LONGVARCHAR) || (lType==LONGNVARCHAR) || 
+          (lType==NCHAR) || (lType==NCLOB) || (lType==NVARCHAR) || (lType==VARCHAR) ||
+          (lType==DATE) || (lType==TIME) || (lType==TIMESTAMP) || (lType==SQLXML) 
+          );
+}
+
+bool SQLTypes::isInt(long lType){
+  return ( (lType == INTEGER) || (lType==BIGINT) || (lType==TINYINT) || (lType==SMALLINT) );
+}
+
+bool SQLTypes::isFloat(long lType){
+  return ((lType == DECIMAL) || (lType==DOUBLE) || (lType==FLOAT) || (lType==NUMERIC) || (lType==REAL) );
+}
+
+bool SQLTypes::isBoolean(long lType){
+  return ((lType == BOOLEAN) || (lType==BIT) );
+}
+
+}}; // namespace zorba, jdbc

=== added directory 'src/jdbc.xq.src/statements'
=== added file 'src/jdbc.xq.src/statements/execute.cpp'
--- src/jdbc.xq.src/statements/execute.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/statements/execute.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "execute.h"
+#include "jdbc.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ExecuteFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lConnectionUUID = JdbcModule::getStringArg(args, 0);
+    String lQuery = JdbcModule::getStringArg(args, 1);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lConnectionUUID, INSTANCE_MAP_CONNECTIONS);
+
+    jobject oStatement = env->CallObjectMethod(oConnection, jConnection.createStatement);
+    CHECK_EXCEPTION
+
+    jstring query =  env->NewStringUTF(lQuery.c_str());
+    env->CallBooleanMethod(oStatement, jStatement.execute, query);
+    CHECK_EXCEPTION
+
+    InstanceMap* lInstanceMap = JdbcModule::getCreateInstanceMap(aDynamincContext, INSTANCE_MAP_STATEMENTS);
+    String resultUUID = JdbcModule::getUUID();
+    lInstanceMap->storeInstance(resultUUID, oStatement);
+
+    result = theFactory->createAnyURI(resultUUID);
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/statements/executequery.cpp'
--- src/jdbc.xq.src/statements/executequery.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/statements/executequery.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "executequery.h"
+#include "jdbc.h"
+#include "jsonitemsequence.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ExecuteQueryFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  jobject result=NULL;
+
+  JDBC_MODULE_TRY
+    String lConnectionUUID = JdbcModule::getStringArg(args, 0);
+    String lQuery = JdbcModule::getStringArg(args, 1);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lConnectionUUID, INSTANCE_MAP_CONNECTIONS);
+
+    jobject oStatement = env->CallObjectMethod(oConnection, jConnection.createStatement);
+    CHECK_EXCEPTION
+
+    jstring query =  env->NewStringUTF(lQuery.c_str());
+    result = env->CallObjectMethod(oStatement, jStatement.executeQuery, query);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new JSONItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/statements/executeupdate.cpp'
--- src/jdbc.xq.src/statements/executeupdate.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/statements/executeupdate.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "executeupdate.h"
+#include "jdbc.h"
+#include "jsonitemsequence.h"
+#include <zorba/singleton_item_sequence.h>
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+ExecuteUpdateFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+  Item result;
+
+  JDBC_MODULE_TRY
+    String lConnectionUUID = JdbcModule::getStringArg(args, 0);
+    String lQuery = JdbcModule::getStringArg(args, 1);
+    
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lConnectionUUID, INSTANCE_MAP_CONNECTIONS);
+
+    jobject oStatement = env->CallObjectMethod(oConnection, jConnection.createStatement);
+    CHECK_EXCEPTION
+
+    jstring query =  env->NewStringUTF(lQuery.c_str());
+    int executionResult = env->CallIntMethod(oStatement, jStatement.executeUpdate, query );
+    CHECK_EXCEPTION
+    result = theFactory->createInt(executionResult);
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new SingletonItemSequence(result));
+}
+
+}}; // namespace zorba, jdbc

=== added directory 'src/jdbc.xq.src/transactions'
=== added file 'src/jdbc.xq.src/transactions/commit.cpp'
--- src/jdbc.xq.src/transactions/commit.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/transactions/commit.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "commit.h"
+#include "jdbc.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+CommitFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+
+  JDBC_MODULE_TRY
+    String lStrUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lStrUUID, INSTANCE_MAP_CONNECTIONS);
+
+    env->CallVoidMethod(oConnection, jConnection.commit);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added file 'src/jdbc.xq.src/transactions/rollback.cpp'
--- src/jdbc.xq.src/transactions/rollback.cpp	1970-01-01 00:00:00 +0000
+++ src/jdbc.xq.src/transactions/rollback.cpp	2014-04-30 23:07:27 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "rollback.h"
+#include "jdbc.h"
+
+namespace zorba
+{
+namespace jdbc
+{
+
+
+ItemSequence_t
+RollbackFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  CHECK_CONNECTION
+
+  JDBC_MODULE_TRY
+    String lConnectionUUID = JdbcModule::getStringArg(args, 0);
+
+    jobject oConnection = JdbcModule::getObject(aDynamincContext, lConnectionUUID, INSTANCE_MAP_CONNECTIONS);
+
+    jclass cConnection = jConnection.classID;
+    env->CallVoidMethod(oConnection, jConnection.rollback);
+    CHECK_EXCEPTION
+
+  JDBC_MODULE_CATCH
+  
+  return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, jdbc

=== added directory 'test'
=== renamed directory 'test' => 'test.moved'
=== added directory 'test/ExpQueryResults'
=== added file 'test/ExpQueryResults/01-creatingDB.xml.res'
--- test/ExpQueryResults/01-creatingDB.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/01-creatingDB.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+true
\ No newline at end of file

=== added file 'test/ExpQueryResults/02-select.xml.res'
--- test/ExpQueryResults/02-select.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/02-select.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+{ "idStudent" : 1, "Name" : "Rodolfo Ochoa", "Address" : "  10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-06", "Weight" : 160, "Score" : 90 }{ "idStudent" : 2, "Name" : "Dana Florescu", "Address" : "10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-13", "Weight" : 150, "Score" : 90 }{ "idStudent" : 3, "Name" : "Cezar Andrei", "Address" : "  10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-27", "Weight" : 160, "Score" : 90 }
\ No newline at end of file

=== added file 'test/ExpQueryResults/03-connect-options.xml.res'
--- test/ExpQueryResults/03-connect-options.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/03-connect-options.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+{ "autocommit" : true, "readonly" : false, "isolation-level" : "REPEATABLE-READ" }
\ No newline at end of file

=== added file 'test/ExpQueryResults/04-set-null-mariadb.xml.res'
--- test/ExpQueryResults/04-set-null-mariadb.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/04-set-null-mariadb.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+{ "columns" : [ { "name" : "String.class", "type" : "String" } ] }
\ No newline at end of file

=== added file 'test/ExpQueryResults/04-set-null.xml.res'
--- test/ExpQueryResults/04-set-null.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/04-set-null.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+{ "columns" : [ { "name" : "java.lang.String", "type" : "VARCHAR" } ] }
\ No newline at end of file

=== added file 'test/ExpQueryResults/05-result-set.xml.res'
--- test/ExpQueryResults/05-result-set.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/05-result-set.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+{ "idStudent" : 1, "Name" : "Rodolfo Ochoa", "Address" : "  10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-06", "Weight" : 160, "Score" : 90 }{ "idStudent" : 2, "Name" : "Dana Florescu", "Address" : "10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-13", "Weight" : 150, "Score" : 90 }{ "idStudent" : 3, "Name" : "Cezar Andrei", "Address" : "  10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-27", "Weight" : 160, "Score" : 90 }
\ No newline at end of file

=== added file 'test/ExpQueryResults/06-prepare.xml.res'
--- test/ExpQueryResults/06-prepare.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/06-prepare.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+{ "idStudent" : 1, "Name" : "Rodolfo Ochoa", "Address" : "  10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-06", "Weight" : 160, "Score" : 90 }{ "idStudent" : 2, "Name" : "Dana Florescu", "Address" : "10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-13", "Weight" : 150, "Score" : 90 }{ "idStudent" : 3, "Name" : "Cezar Andrei", "Address" : "  10 Van De Graaff Dr # 1  Burlington, MA 01803", "Birthday" : "2012-12-27", "Weight" : 160, "Score" : 90 }
\ No newline at end of file

=== added file 'test/ExpQueryResults/07-prepare.xml.res'
--- test/ExpQueryResults/07-prepare.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/07-prepare.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+3
\ No newline at end of file

=== added file 'test/ExpQueryResults/08-deletingDB.xml.res'
--- test/ExpQueryResults/08-deletingDB.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/08-deletingDB.xml.res	2014-04-30 23:07:27 +0000
@@ -0,0 +1,1 @@
+true
\ No newline at end of file

=== added directory 'test/Queries'
=== added file 'test/Queries/01-creatingDB.xq'
--- test/Queries/01-creatingDB.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/01-creatingDB.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,63 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/",
+  "user" : "root",
+  "password" : ""});
+
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School01` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+  
+jdbc:execute-update($connection, "USE `School01`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+
+if (jdbc:is-connected($connection))
+ then { true() }
+ else false()

=== added file 'test/Queries/02-select.xq'
--- test/Queries/02-select.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/02-select.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,70 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/",
+  "user" : "root",
+  "password" : ""});
+  
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School02` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+  
+jdbc:execute-update($connection, "USE `School02`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+
+variable $data := jdbc:execute-query($connection, "
+SELECT A.idStudent, A.Name, Address, Birthday, Weight, Score 
+FROM students A 
+INNER JOIN scores B ON (A.idStudent = B.idStudent)
+WHERE idCourse=1
+");
+
+if (jdbc:is-connected($connection))
+ then { $data }
+ else false()

=== added file 'test/Queries/03-connect-options.xq'
--- test/Queries/03-connect-options.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/03-connect-options.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,64 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/",
+  "user" : "root",
+  "password" : ""});
+  
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School03` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+
+jdbc:execute-update($connection, "USE `School03`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+variable $data := jdbc:connection-options($connection);
+
+if (jdbc:is-connected($connection))
+ then { $data }
+ else false()

=== added file 'test/Queries/04-set-null.spec'
--- test/Queries/04-set-null.spec	1970-01-01 00:00:00 +0000
+++ test/Queries/04-set-null.spec	2014-04-30 23:07:27 +0000
@@ -0,0 +1,3 @@
+Result: $RBKT_SRC_DIR/ExpQueryResults/04-set-null.xml.res
+# Additional expected result when using MariaDB JDBC driver
+Result: $RBKT_SRC_DIR/ExpQueryResults/04-set-null-mariadb.xml.res

=== added file 'test/Queries/04-set-null.xq'
--- test/Queries/04-set-null.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/04-set-null.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,73 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/?generateSimpleParameterMetadata=true",
+  "user" : "root",
+  "password" : ""});
+  
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School04` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+
+jdbc:execute-update($connection, "USE `School04`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+variable $prep-stat := jdbc:prepare-statement($connection, "
+SELECT A.idStudent, A.Name, Address, Birthday, Weight, Score 
+FROM students A 
+INNER JOIN scores B ON (A.idStudent = B.idStudent)
+WHERE idCourse=?
+");
+
+jdbc:set-null($prep-stat,1);
+
+variable $metadata := jdbc:parameter-metadata($prep-stat);
+
+if (jdbc:is-connected($connection))
+ then { $metadata }
+ else false()

=== added file 'test/Queries/05-result-set.xq'
--- test/Queries/05-result-set.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/05-result-set.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,71 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/",
+  "user" : "root",
+  "password" : ""});
+  
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School05` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+
+jdbc:execute-update($connection, "USE `School05`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+variable $data-set := jdbc:execute($connection, "
+SELECT A.idStudent, A.Name, Address, Birthday, Weight, Score 
+FROM students A 
+INNER JOIN scores B ON (A.idStudent = B.idStudent)
+WHERE idCourse=1
+");
+
+variable $data := jdbc:result-set($data-set);
+
+if (jdbc:is-connected($connection))
+ then { $data }
+ else false()

=== added file 'test/Queries/06-prepare.xq'
--- test/Queries/06-prepare.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/06-prepare.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,75 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/",
+  "user" : "root",
+  "password" : ""});
+  
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School06` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+
+jdbc:execute-update($connection, "USE `School06`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+
+variable $prep-stat := jdbc:prepare-statement($connection, "
+SELECT A.idStudent, A.Name, Address, Birthday, Weight, Score 
+FROM students A 
+INNER JOIN scores B ON (A.idStudent = B.idStudent)
+WHERE idCourse=?
+");
+jdbc:set-numeric($prep-stat, 1, 1.0);
+
+variable $data-set := jdbc:execute-prepared($prep-stat);
+
+variable $data := jdbc:result-set($data-set);
+
+if (jdbc:is-connected($connection))
+ then { $data }
+ else false()

=== added file 'test/Queries/07-prepare.xq'
--- test/Queries/07-prepare.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/07-prepare.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,75 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/?generateSimpleParameterMetadata=true",
+  "user" : "root",
+  "password" : ""});
+  
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School07` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+
+jdbc:execute-update($connection, "USE `School07`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+variable $prep-stat := jdbc:prepare-statement($connection, "
+SELECT A.idStudent, A.Name, Address, Birthday, Weight, Score 
+FROM students A 
+INNER JOIN scores B ON (A.idStudent = B.idStudent)
+WHERE idCourse=?
+");
+
+jdbc:set-numeric($prep-stat,1,1);
+
+variable $data-set := jdbc:execute-prepared($prep-stat);
+
+variable $rows := jdbc:affected-rows($data-set);
+
+if (jdbc:is-connected($connection))
+ then { $rows }
+ else false()

=== added file 'test/Queries/08-deletingDB.xq'
--- test/Queries/08-deletingDB.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/08-deletingDB.xq	2014-04-30 23:07:27 +0000
@@ -0,0 +1,62 @@
+import module namespace jdbc = "http://www.zorba-xquery.com/modules/jdbc";;
+
+variable $connection := jdbc:connect({
+  "url": "jdbc:mysql://localhost:3307/",
+  "user" : "root",
+  "password" : ""});
+  
+jdbc:execute-update($connection, "CREATE DATABASE /*!32312 IF NOT EXISTS*/`School08` /*!40100 DEFAULT CHARACTER SET latin1 */;");
+
+jdbc:execute-update($connection, "USE `School08`;");
+
+(: Table structures :)
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `courses`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `courses` (
+  `idCourse` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Course` varchar(100) DEFAULT NULL,
+  PRIMARY KEY (`idCourse`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `courses`(`idCourse`,`Course`) VALUES (1,'Introduction to DBs'),(2,'Parallel Programming'),(3,'OpenSource XQuery Processors'),(4,'NoSQL Databases');
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `scores`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `scores` (
+  `idCourse` bigint(20) DEFAULT NULL,
+  `idStudent` bigint(20) DEFAULT NULL,
+  `Score` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT INTO `scores`(`idCourse`,`idStudent`,`Score`) VALUES (1,1,90),(1,2,90),(1,3,90),(2,2,90),(2,2,90),(2,3,90);
+");
+
+jdbc:execute-update($connection, "
+DROP TABLE IF EXISTS `students`;
+");
+jdbc:execute-update($connection, "
+CREATE TABLE `students` (
+  `idStudent` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `Name` varchar(100) DEFAULT NULL,
+  `Address` varchar(200) DEFAULT NULL,
+  `Birthday` date DEFAULT NULL,
+  `Weight` float DEFAULT NULL,
+  PRIMARY KEY (`idStudent`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+");
+jdbc:execute-update($connection, "
+INSERT  INTO `students`(`idStudent`,`Name`,`Address`,`Birthday`,`Weight`) VALUES (1,'Rodolfo Ochoa','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-06',160),(2,'Dana Florescu','10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-13',150),(3,'Cezar Andrei','  10 Van De Graaff Dr # 1  Burlington, MA 01803','2012-12-27',160);
+");
+
+
+if (jdbc:is-connected($connection))
+ then { true() }
+ else false()


References