Added: openoffice/trunk/main/connectivity/java/sdbc_jdbc/build.xml
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/build.xml?rev=1814552&view=auto
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_jdbc/build.xml (added)
+++ openoffice/trunk/main/connectivity/java/sdbc_jdbc/build.xml Wed Nov 8
04:17:25 2017
@@ -0,0 +1,250 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ ***********************************************************-->
+
+
+<project name="sdbc_jdbc" default="main" basedir=".">
+
+ <!-- ================================================================= -->
+ <!-- settings -->
+ <!-- ================================================================= -->
+
+ <!-- global properties -->
+ <property file="../../../ant.properties"/>
+ <!-- version info -->
+ <property file="../../../solenv/inc/minor.mk"/>
+
+ <!-- name of this sub target used in recursive builds -->
+ <property name="target" value="sdbc_jdbc"/>
+
+ <!-- name of jar file created, without .jar extension -->
+ <property name="jarname" value="sdbc_jdbc"/>
+
+ <!-- relative path to project directory -->
+ <property name="prj" value="../.."/>
+
+ <!-- build output directory -->
+ <!-- FIXME: there are also extremely rare/obsolete
dbcs/bndchk/truetime/hbtoolkit cases in main/solenv/inc/settings.mk -->
+ <condition property="out" value="${prj}/${OUTPATH}.cap">
+ <isset property="${profile}"/>
+ </condition>
+ <condition property="out" value="${prj}/${OUTPATH}.pro">
+ <isset property="${PRODUCT}"/>
+ </condition>
+ <property name="out" value="${prj}/${OUTPATH}"/>
+
+ <!-- build directories -->
+ <property name="build.dir" value="${out}"/>
+ <property name="build.class" value="${build.dir}/class/${target}"/>
+ <property name="build.misc" value="${build.dir}/misc/${target}"/>
+
+ <!-- start of java source code package structure -->
+ <property name="java.dir" value="src"/>
+
+ <!-- define how to handle CLASSPATH environment -->
+ <property name="build.sysclasspath" value="ignore"/>
+
+ <!-- classpath settings for compile and javadoc tasks -->
+ <condition property="jar-class-path" value="${COMMONS_LANG_JAR}"
else="commons-lang3-3.3.jar">
+ <equals arg1="${SYSTEM_APACHE_COMMONS}" arg2="YES"/>
+ </condition>
+ <condition property="commons-lang-jar" value="${COMMONS_LANG_JAR}"
else="${OUTDIR}/bin/commons-lang3-3.3.jar">
+ <equals arg1="${SYSTEM_APACHE_COMMONS}" arg2="YES"/>
+ </condition>
+ <path id="classpath">
+ <pathelement location="${OUTDIR}/bin/juh.jar"/>
+ <pathelement location="${OUTDIR}/bin/jurt.jar"/>
+ <pathelement location="${OUTDIR}/bin/ridl.jar"/>
+ <pathelement location="${OUTDIR}/bin/unoil.jar"/>
+ <pathelement location="${out}/class/dbtools/dbtools.jar"/>
+ <!-- 3rd party libs -->
+ <pathelement location="${commons-lang-jar}"/>
+ </path>
+
+ <!-- name to display in documentation -->
+ <property name="docname" value="sdbc_jdbc"/>
+
+ <!-- set "modern" java compiler -->
+ <property name="build.compiler" value="modern"/>
+
+ <!-- set wether we want to compile with debug information -->
+ <property name="debug" value="on"/>
+
+ <!-- set wether we want to compile with optimisation -->
+ <property name="optimize" value="off"/>
+
+ <!-- set wether we want to compile with or without deprecation -->
+ <property name="deprecation" value="on"/>
+
+ <target name="info">
+ <echo message="--------------------"/>
+ <echo message="${target}"/>
+ <echo message="--------------------"/>
+ </target>
+
+ <!-- ================================================================= -->
+ <!-- custom targets -->
+ <!-- ================================================================= -->
+
+ <!-- the main target, called in recursive builds -->
+ <target name="main" depends="info,prepare,compile,jar,javadoc,zipdoc"/>
+
+ <!-- prepare output directories -->
+ <target name="prepare">
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.dir}/doc/${target}"/>
+ <mkdir dir="${build.class}"/>
+ <mkdir dir="${build.misc}"/>
+ </target>
+
+
+ <target name="res" depends="prepare">
+ <copy todir="${build.class}">
+ <fileset dir="${java.dir}">
+ <include name="**/*.properties"/>
+ <include name="**/*.css"/>
+ <include name="**/*.dtd"/>
+ <include name="**/*.form"/>
+ <include name="**/*.gif "/>
+ <include name="**/*.htm"/>
+ <include name="**/*.html"/>
+ <include name="**/*.js"/>
+ <include name="**/*.mod"/>
+ <include name="**/*.sql"/>
+ <include name="**/*.xml"/>
+ <include name="**/*.xsl"/>
+ <include name="**/*.map"/>
+
+ </fileset>
+ </copy>
+ </target>
+
+
+ <target name="compile" depends="prepare,res">
+ <javac destdir="${build.class}"
+ debug="${debug}"
+ debuglevel="lines,vars,source"
+ deprecation="${deprecation}"
+ optimize="${optimize}"
+ classpathref="classpath">
+ <src path="${java.dir}"/>
+ <include name="**/*.java"/>
+ </javac>
+ </target>
+
+ <!-- check if javadoc is up to date -->
+ <target name="javadoc_check" depends="prepare" if="build.dir">
+ <uptodate property="javadocBuild.notRequired" value="true"
+ targetfile="${build.dir}/doc/${target}/${target}_javadoc.zip">
+ <srcfiles dir="${java.dir}" includes="**/*.java"/>
+ </uptodate>
+ </target>
+
+ <!-- generate java documentation -->
+ <target name="javadoc" depends="prepare,javadoc_check,compile"
+ unless="javadocBuild.notRequired"
+ if="build.dir">
+
+ <javadoc destdir="${build.dir}/doc/${target}/javadoc"
+ verbose="false"
+ author="false"
+ nodeprecated="true"
+ nodeprecatedlist="true"
+ use="true"
+ Doctitle="${docname}"
+ windowtitle="${docname}"
+ classpathref="classpath">
+
+ <packageset dir="${java.dir}" defaultexcludes="yes">
+ <include name="com/**"/>
+ <include name="org/**"/>
+ </packageset>
+
+ <link offline="true" href="http://java.sun.com/j2se/1.4.2/docs/api"
+ packagelistLoc="${common.doc}/jdk1.4.2"/>
+ <link offline="true"
+ href="http://java.sun.com/products/servlet/2.3/javadoc"
+ packagelistLoc="${common.doc}/servlet2.3"/>
+ <link offline="true"
+ href="http://logging.apache.org/log4j/docs/api"
+ packagelistLoc="${common.doc}/log4j-1.2.8"/>
+ <link offline="true"
+
href="http://java.sun.com/products/javabeans/glasgow/javadocs"
+ packagelistLoc="${common.doc}/jaf-1.0.2"/>
+ <link offline="true"
+ href="http://java.sun.com/products/javamail/javadocs"
+ packagelistLoc="${common.doc}/javamail-1.3.1"/>
+ <link offline="true"
+ href="http://ws.apache.org/soap/docs"
+ packagelistLoc="${common.doc}/soap-2.3.1"/>
+
+ <bottom><i>Copyright &#169; 2004 Sun Microsystems, Inc.,
901 San Antonio Road, Palo Alto, CA 94303 USA</i></bottom>
+ <header>${docname}</header>
+
+ </javadoc>
+ </target>
+
+ <!-- zip documentation and store in build/doc/${target} -->
+ <target name="zipdoc" depends="javadoc" if="build.dir"
unless="javadocBuild.notRequired">
+ <zip zipfile="${build.dir}/doc/${target}/${target}_javadoc.zip"
+ basedir="${build.dir}/doc/${target}/javadoc"
+ update="true"/>
+ </target>
+
+ <!-- clean up -->
+ <target name="clean" depends="prepare">
+ <delete dir="${build.class}" includeEmptyDirs="true"/>
+ <delete dir="${build.dir}/doc/${target}" includeEmptyDirs="true"/>
+ </target>
+
+ <!-- create jar file -->
+ <target name="jar" depends="prepare,compile" if="build.class">
+ <jar jarfile="${build.class}/${jarname}.jar"
+ basedir="${build.class}">
+ <manifest>
+ <attribute name="Class-Path" value="${jar-class-path} juh.jar
jurt.jar ridl.jar unoil.jar dbtools.jar"/>
+ <attribute name="Solar-Version" value="${RSCREVISION}"/>
+ <attribute name="RegistrationClassName"
value="com.sun.star.comp.sdbc.JDBCDriver"/>
+ <attribute name="Sealed" value="true"/>
+ <attribute name="UNO-Type-Path" value=""/>
+ </manifest>
+ <include name="**/*.class"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.css"/>
+ <include name="**/*.dtd"/>
+ <include name="**/*.form"/>
+ <include name="**/*.gif "/>
+ <include name="**/*.htm"/>
+ <include name="**/*.html"/>
+ <include name="**/*.js"/>
+ <include name="**/*.mod"/>
+ <include name="**/*.sql"/>
+ <include name="**/*.xml"/>
+ <include name="**/*.xsl"/>
+ <include name="**/*.map"/>
+ </jar>
+ </target>
+
+ <target name="test" depends="prepare">
+ </target>
+
+</project>
+
Propchange: openoffice/trunk/main/connectivity/java/sdbc_jdbc/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openoffice/trunk/main/connectivity/java/sdbc_jdbc/build.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.component
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.component?rev=1814552&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.component
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.xml
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.xml?rev=1814552&view=auto
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.xml (added)
+++ openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.xml Wed Nov 8
04:17:25 2017
@@ -0,0 +1,50 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN"
"module-description.dtd">
+<!--***********************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ ***********************************************************-->
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> jdbc </module-name>
+ <component-description>
+ <author>Ocke Janssen</author>
+ <name>com.sun.star.comp.sdbc.JDBCDriver</name>
+ <description>
+ This is the implementation of the sdbc-jdbc bridge.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service> com.sun.star.sdbc.Driver
</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
+
+
Propchange: openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openoffice/trunk/main/connectivity/java/sdbc_jdbc/jdbc.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: openoffice/trunk/main/connectivity/java/sdbc_jdbc/makefile.mk
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/makefile.mk?rev=1814552&view=auto
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_jdbc/makefile.mk (added)
+++ openoffice/trunk/main/connectivity/java/sdbc_jdbc/makefile.mk Wed Nov 8
04:17:25 2017
@@ -0,0 +1,50 @@
+#**************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+#**************************************************************
+
+
+
+PRJ=..$/..
+PRJNAME=connectivity
+TARGET=sdbc_jdbc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+.IF defined(debug) || defined(DEBUG)
+ANTDEBUG=true
+.ELSE
+ANTDEBUG=off
+.ENDIF
+
+ANT_FLAGS+=-Dantdebug=$(ANTDEBUG)
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : $(PRJ)$/target.pmk
+
+ALLTAR: ANTBUILD $(MISC)/jdbc.component
+
+$(MISC)/jdbc.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ jdbc.component
+ $(XSLTPROC) --nonet --stringparam uri
'$(COMPONENTPREFIX_URE_JAVA)sdbc_jdbc.jar' \
+ -o $@ $(SOLARENV)/bin/createcomponent.xslt jdbc.component
+
Added: openoffice/trunk/main/connectivity/java/sdbc_jdbc/sdbc_jdbc.xcu
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/sdbc_jdbc.xcu?rev=1814552&view=auto
==============================================================================
Binary file - no diff available.
Propchange: openoffice/trunk/main/connectivity/java/sdbc_jdbc/sdbc_jdbc.xcu
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,69 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class BoundedInputStream extends InputStream {
+ private InputStream is;
+ private long remaining;
+
+ public BoundedInputStream(InputStream is, long max) {
+ this.is = is;
+ this.remaining = max;
+ }
+
+ @Override
+ public int available() throws IOException {
+ return is.available();
+ }
+
+ @Override
+ public void close() throws IOException {
+ is.close();
+ }
+
+ @Override
+ public int read() throws IOException {
+ if (remaining <= 0) {
+ return -1;
+ }
+ int ret = is.read();
+ if (ret >= 0) {
+ --remaining;
+ }
+ return ret;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (remaining <= 0) {
+ return -1;
+ }
+ long max = Math.max(remaining, len);
+ int bytesRead = is.read(b, off, (int)max);
+ if (bytesRead > 0) {
+ remaining -= bytesRead;
+ }
+ return bytesRead;
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/BoundedInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,167 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import java.lang.ref.WeakReference;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.openoffice.comp.sdbc.dbtools.comphelper.CompHelper;
+
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uri.UriReferenceFactory;
+import com.sun.star.uri.XUriReferenceFactory;
+import com.sun.star.uri.XVndSunStarExpandUrlReference;
+import com.sun.star.util.XMacroExpander;
+
+/**
+ * A map from pairs of (classPath, name) to pairs of weak Java
+ * references to (ClassLoader, Class) is maintained, so that a class is only
+ * loaded once.
+ *
+ * It may happen that the weak reference to the ClassLoader becomes null while
+ * the reference to the Class remains non-null (in case the Class was actually
+ * loaded by some parent of the ClassLoader), in which case the ClassLoader is
+ * resurrected (which cannot cause any classes to be loaded multiple times, as
+ * the ClassLoader is no longer reachable, so no classes it has ever loaded are
+ * still reachable).
+ *
+ * Similarly, it may happen that the weak reference to the Class becomes null
+ * while the reference to the ClassLoader remains non-null, in which case the
+ * Class is simply re-loaded.
+ */
+public class ClassMap {
+ public static class ClassLoaderAndClass {
+ private ClassLoader classLoader;
+ private Class<?> classObject;
+
+ public ClassLoaderAndClass(ClassLoader classLoader, Class<?>
classObject) {
+ this.classLoader = classLoader;
+ this.classObject = classObject;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public Class<?> getClassObject() {
+ return classObject;
+ }
+ }
+
+ private static class ClassMapEntry {
+ String classPath;
+ String className;
+ WeakReference<ClassLoader> classLoader;
+ WeakReference<Class<?>> classObject;
+ }
+
+ private final LinkedList<ClassMapEntry> map = new LinkedList<>();
+
+ public synchronized ClassLoaderAndClass loadClass(XComponentContext
context, String classPath, String className)
+ throws MalformedURLException, ClassNotFoundException {
+
+ ClassLoader classLoader = null;
+ Class<?> classObject = null;
+ // Prune dangling weak references from the list while searching for a
match,
+ // so that the list cannot grow unbounded:
+ ClassMapEntry matchingEntry = null;
+ for (Iterator<ClassMapEntry> it = map.iterator(); it.hasNext();) {
+ ClassMapEntry entry = it.next();
+ classLoader = entry.classLoader.get();
+ classObject = entry.classObject.get();
+ if (classLoader == null && classObject == null) {
+ it.remove();
+ } else if (entry.classPath.equals(classPath) &&
entry.className.equals(className)) {
+ matchingEntry = entry;
+ break;
+ }
+ }
+ if (classLoader == null || classObject == null) {
+ if (matchingEntry == null) {
+ // Push a new ClassMapEntry (which can potentially fail) before
+ // loading the class, so that it never happens that a class is
+ // loaded but not added to the map (which could have effects
on the
+ // JVM that are not easily undone). If the pushed
ClassMapEntry is
+ // not used after all (return false, etc.) it will be pruned
on next
+ // call because its classLoader/classObject are null:
+ matchingEntry = new ClassMapEntry();
+ matchingEntry.classPath = classPath;
+ matchingEntry.className = className;
+ map.addFirst(matchingEntry);
+ }
+ if (classLoader == null) {
+ List<URL> urls = translateToUrls(context, classPath);
+ classLoader = new URLClassLoader(urls.toArray(new URL[0]));
+ }
+ if (classObject == null) {
+ classObject = classLoader.loadClass(className);
+ }
+ matchingEntry.classLoader = new
WeakReference<ClassLoader>(classLoader);
+ matchingEntry.classObject = new
WeakReference<Class<?>>(classObject);
+ }
+ return new ClassLoaderAndClass(classLoader, classObject);
+ }
+
+ private static List<URL> translateToUrls(XComponentContext context, String
classPath) throws MalformedURLException {
+ StringTokenizer tokenizer = new StringTokenizer(classPath, " ", false);
+ ArrayList<URL> urls = new ArrayList<>();
+ while (tokenizer.hasMoreTokens()) {
+ String url = tokenizer.nextToken();
+ XUriReferenceFactory uriReferenceFactory = null;
+ XVndSunStarExpandUrlReference expUrl = null;
+ XMacroExpander macroExpander = null;
+ try {
+ uriReferenceFactory = UriReferenceFactory.create(context);
+ expUrl = UnoRuntime.queryInterface(
+ XVndSunStarExpandUrlReference.class,
uriReferenceFactory.parse(url));
+ if (expUrl != null) {
+ macroExpander = UnoRuntime.queryInterface(
+ XMacroExpander.class,
+
context.getValueByName("/singletons/com.sun.star.util.theMacroExpander"));
+ try {
+ url = expUrl.expand(macroExpander);
+ } catch (IllegalArgumentException
illegalArgumentException) {
+ throw new RuntimeException(
+ "com.sun.star.lang.IllegalArgumentException: "
+ illegalArgumentException.getMessage(),
+ illegalArgumentException);
+ }
+ }
+ } finally {
+ CompHelper.disposeComponent(uriReferenceFactory);
+ CompHelper.disposeComponent(expUrl);
+ CompHelper.disposeComponent(macroExpander);
+ }
+ URL javaURL = new URL(url);
+ urls.add(javaURL);
+ }
+ return urls;
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ClassMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ConnectionLog.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ConnectionLog.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ConnectionLog.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ConnectionLog.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,70 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import
org.apache.openoffice.comp.sdbc.dbtools.comphelper.ResourceBasedEventLogger;
+
+public class ConnectionLog extends ResourceBasedEventLogger {
+ public static enum ObjectType {
+ CONNECTION,
+ STATEMENT,
+ RESULT
+ }
+
+ private static final AtomicInteger[] uniqueIds;
+
+ static
+ {
+ uniqueIds = new AtomicInteger[ObjectType.values().length];
+ for (int i = 0; i < uniqueIds.length; i++) {
+ uniqueIds[i] = new AtomicInteger(0);
+ }
+ }
+
+ private final int objectId;
+
+ public ConnectionLog(ResourceBasedEventLogger logger, ObjectType
objectType) {
+ super(logger);
+ objectId = uniqueIds[objectType.ordinal()].getAndIncrement();
+ }
+
+ public int getObjectId() {
+ return objectId;
+ }
+
+ @Override
+ public boolean log(int logLevel, int messageResID, Object... arguments) {
+ Object[] argsWithId = new Object[arguments.length + 1];
+ argsWithId[0] = objectId;
+ System.arraycopy(arguments, 0, argsWithId, 1, arguments.length);
+ return super.log(logLevel, messageResID, argsWithId);
+ }
+
+ @Override
+ public boolean logp(int logLevel, int messageResID, Object... arguments) {
+ Object[] argsWithId = new Object[arguments.length + 1];
+ argsWithId[0] = objectId;
+ System.arraycopy(arguments, 0, argsWithId, 1, arguments.length);
+ return super.logp(logLevel, messageResID, arguments);
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ConnectionLog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,37 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+public class ContextClassLoaderScope implements AutoCloseable {
+ private Thread currentThread;
+ private ClassLoader oldClassLoader;
+
+ public ContextClassLoaderScope(ClassLoader classLoader) {
+ currentThread = Thread.currentThread();
+ oldClassLoader = currentThread.getContextClassLoader();
+ currentThread.setContextClassLoader(classLoader);
+ }
+
+ @Override
+ public void close() {
+ currentThread.setContextClassLoader(oldClassLoader);
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/ContextClassLoaderScope.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,196 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import org.apache.openoffice.comp.sdbc.dbtools.comphelper.CompHelper;
+import
org.apache.openoffice.comp.sdbc.dbtools.comphelper.ResourceBasedEventLogger;
+import org.apache.openoffice.comp.sdbc.dbtools.util.Resources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.SharedResources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lib.uno.helper.ComponentBase;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.logging.LogLevel;
+import com.sun.star.sdbc.DriverPropertyInfo;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.sdbc.XDriver;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.XComponentContext;
+
+public class JDBCDriver extends ComponentBase implements XServiceInfo, XDriver
{
+ private static String[] services = new String[] {
+ "com.sun.star.sdbc.Driver"
+ };
+ private XComponentContext context;
+ private ResourceBasedEventLogger logger;
+
+ public static XSingleComponentFactory __getComponentFactory(String
implName) {
+ XSingleComponentFactory xSingleComponentFactory = null;
+ if (implName.equals(getImplementationNameStatic())) {
+ xSingleComponentFactory =
Factory.createComponentFactory(JDBCDriver.class,
+ getImplementationNameStatic(), services);
+ }
+ return xSingleComponentFactory;
+ }
+
+ public JDBCDriver(XComponentContext componentContext) {
+ this.context = componentContext;
+ SharedResources.registerClient(componentContext);
+ logger = new ResourceBasedEventLogger(context, "sdbcl",
"org.openoffice.sdbc.jdbcBridge");
+ }
+
+ public XComponentContext getContext() {
+ return context;
+ }
+
+ public ResourceBasedEventLogger getLogger() {
+ return logger;
+ }
+
+ private static String getImplementationNameStatic() {
+ // this name is referenced in the configuration and in the jdbc.xml
+ // Please take care when changing it.
+ return JDBCDriver.class.getName();
+ }
+
+ // XComponent:
+
+ @Override
+ protected synchronized void postDisposing() {
+ context = null;
+ SharedResources.revokeClient();
+ }
+
+ // XServiceInfo:
+
+ @Override
+ public String getImplementationName() {
+ return getImplementationNameStatic();
+ }
+
+ @Override
+ public String[] getSupportedServiceNames() {
+ return services.clone();
+ }
+
+ @Override
+ public boolean supportsService(String serviceName) {
+ for (String service : getSupportedServiceNames()) {
+ if (service.equals(serviceName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // XDriver:
+
+ @Override
+ public boolean acceptsURL(String url) throws SQLException {
+ // don't ask the real driver for the url
+ // I feel responsible for all jdbc url's
+ return url.startsWith("jdbc:");
+ }
+
+ @Override
+ public synchronized XConnection connect(String url, PropertyValue[] info)
throws SQLException {
+ checkDisposed();
+ logger.log(LogLevel.INFO, Resources.STR_LOG_DRIVER_CONNECTING_URL,
url);
+ XConnection out = null;
+ if (acceptsURL(url)) {
+ JavaSQLConnection connection = new JavaSQLConnection(this);
+ out = connection;
+ if (!connection.construct(url, info)) {
+ // an error occurred and the java driver didn't throw an
exception
+ CompHelper.disposeComponent(out);
+ out = null;
+ } else {
+ logger.log(LogLevel.INFO, Resources.STR_LOG_DRIVER_SUCCESS);
+ }
+ }
+ return out;
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return 1;
+ }
+
+ @Override
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(String url, PropertyValue[]
info) throws SQLException {
+ if (!acceptsURL(url)) {
+ String message =
SharedResources.getInstance().getResourceString(Resources.STR_URI_SYNTAX_ERROR);
+ throw new SQLException(message, this,
StandardSQLState.SQL_GENERAL_ERROR.text(), 0, Any.VOID);
+ }
+ String[] booleanValues = { "false", "true" };
+ return new DriverPropertyInfo [] {
+ new DriverPropertyInfo(
+ "JavaDriverClass", "The JDBC driver class name.",
+ true, "", new String[0]),
+ new DriverPropertyInfo(
+ "JavaDriverClassPath", "The class path where to look
for the JDBC driver.",
+ true, "", new String[0]),
+ new DriverPropertyInfo(
+ "SystemProperties", "Additional properties to set at
java.lang.System before loading the driver.",
+ true, "", new String[0]),
+ new DriverPropertyInfo(
+ "ParameterNameSubstitution", "Change named parameters
with '?'.",
+ false, "false", booleanValues),
+ new DriverPropertyInfo(
+ "IgnoreDriverPrivileges", "Ignore the privileges from
the database driver.",
+ false, "false", booleanValues),
+ new DriverPropertyInfo(
+ "IsAutoRetrievingEnabled", "Retrieve generated
values.",
+ false, "false", booleanValues),
+ new DriverPropertyInfo(
+ "AutoRetrievingStatement", "Auto-increment statement.",
+ false, "", new String[0]),
+ new DriverPropertyInfo(
+ "GenerateASBeforeCorrelationName", "Generate AS before
table correlation names.",
+ false, "true", booleanValues),
+ new DriverPropertyInfo(
+ "IgnoreCurrency", "Ignore the currency field from the
ResultsetMetaData.",
+ false, "false", booleanValues),
+ new DriverPropertyInfo(
+ "EscapeDateTime", "Escape date time format.",
+ false, "true", booleanValues),
+ new DriverPropertyInfo(
+ "TypeInfoSettings", "Defines how the type info of the
database metadata should be manipulated.",
+ false, "", new String[0]),
+ new DriverPropertyInfo(
+ "ImplicitCatalogRestriction", "The catalog which
should be used in getTables calls, when the caller passed NULL.",
+ false, "", new String[0]),
+ new DriverPropertyInfo(
+ "ImplicitSchemaRestriction", "The schema which should
be used in getTables calls, when the caller passed NULL.",
+ false, "", new String[0])
+ };
+
+ }
+}
\ No newline at end of file
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JDBCDriver.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLArray.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLArray.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLArray.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLArray.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,115 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import
org.apache.openoffice.comp.sdbc.dbtools.comphelper.ResourceBasedEventLogger;
+import org.apache.openoffice.comp.sdbc.dbtools.util.Resources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.SharedResources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lib.uno.helper.ComponentBase;
+import com.sun.star.logging.LogLevel;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XArray;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.uno.Any;
+
+public class JavaSQLArray extends ComponentBase implements XArray {
+ private ResourceBasedEventLogger logger;
+ private java.sql.Array jdbcArray;
+
+ public JavaSQLArray(ResourceBasedEventLogger logger, java.sql.Array
jdcbArray) {
+ this.logger = logger;
+ this.jdbcArray = jdcbArray;
+ }
+
+ @Override
+ protected void postDisposing() {
+ try {
+ jdbcArray.free();
+ } catch (java.sql.SQLException jdbcSQLException) {
+ logger.log(LogLevel.WARNING, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public Object[] getArray(XNameAccess typeMap) throws SQLException {
+ if (typeMap.hasElements()) {
+ throw new SQLException(
+
SharedResources.getInstance().getResourceStringWithSubstitution(
+ Resources.STR_UNSUPPORTED_FEATURE,
"$featurename$", "Type maps"),
+ this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(),
0, Any.VOID);
+ }
+ return new Object[0];
+ }
+
+ @Override
+ public Object[] getArrayAtIndex(int index, int count, XNameAccess typeMap)
throws SQLException {
+ if (typeMap.hasElements()) {
+ throw new SQLException(
+
SharedResources.getInstance().getResourceStringWithSubstitution(
+ Resources.STR_UNSUPPORTED_FEATURE,
"$featurename$", "Type maps"),
+ this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(),
0, Any.VOID);
+ }
+ return new Object[0];
+ }
+
+ @Override
+ public int getBaseType() throws SQLException {
+ try {
+ return jdbcArray.getBaseType();
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public String getBaseTypeName() throws SQLException {
+ try {
+ return jdbcArray.getBaseTypeName();
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public XResultSet getResultSet(XNameAccess typeMap) throws SQLException {
+ if (typeMap.hasElements()) {
+ throw new SQLException(
+
SharedResources.getInstance().getResourceStringWithSubstitution(
+ Resources.STR_UNSUPPORTED_FEATURE,
"$featurename$", "Type maps"),
+ this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(),
0, Any.VOID);
+ }
+ return null;
+ }
+
+ @Override
+ public XResultSet getResultSetAtIndex(int index, int count, XNameAccess
typeMap) throws SQLException {
+ if (typeMap.hasElements()) {
+ throw new SQLException(
+
SharedResources.getInstance().getResourceStringWithSubstitution(
+ Resources.STR_UNSUPPORTED_FEATURE,
"$featurename$", "Type maps"),
+ this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(),
0, Any.VOID);
+ }
+ return null;
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLArray.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLBlob.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLBlob.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLBlob.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLBlob.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,109 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import java.io.InputStream;
+
+import
org.apache.openoffice.comp.sdbc.dbtools.comphelper.ResourceBasedEventLogger;
+import org.apache.openoffice.comp.sdbc.dbtools.util.Resources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.SharedResources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState;
+
+import com.sun.star.io.XInputStream;
+import com.sun.star.lib.uno.adapter.InputStreamToXInputStreamAdapter;
+import com.sun.star.lib.uno.helper.ComponentBase;
+import com.sun.star.logging.LogLevel;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XBlob;
+import com.sun.star.uno.Any;
+
+public class JavaSQLBlob extends ComponentBase implements XBlob {
+ private ResourceBasedEventLogger logger;
+ private java.sql.Blob jdbcBlob;
+
+ public JavaSQLBlob(ResourceBasedEventLogger logger, java.sql.Blob
jdbcBlob) {
+ this.logger = logger;
+ this.jdbcBlob = jdbcBlob;
+ }
+
+ @Override
+ protected void postDisposing() {
+ try {
+ jdbcBlob.free();
+ } catch (java.sql.SQLException jdbcSQLException) {
+ logger.log(LogLevel.WARNING, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public XInputStream getBinaryStream() throws SQLException {
+ try {
+ InputStream inputStream = jdbcBlob.getBinaryStream();
+ if (inputStream != null) {
+ return new InputStreamToXInputStreamAdapter(inputStream);
+ } else {
+ return null;
+ }
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public byte[] getBytes(long pos, int length) throws SQLException {
+ try {
+ return jdbcBlob.getBytes(pos, length);
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public long length() throws SQLException {
+ try {
+ return jdbcBlob.length();
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public long position(byte[] pattern, long start) throws SQLException {
+ try {
+ return jdbcBlob.position(pattern, start);
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public long positionOfBlob(XBlob arg0, long arg1) throws SQLException {
+ // this was put here in CWS warnings01. The previous implementation
was defective, as it did ignore
+ // the pattern parameter. Since the effort for proper implementation
is rather high - we would need
+ // to translated patter into a byte[] -, we defer this functionality
for the moment (hey, it was
+ // unusable, anyway)
+ // 2005-11-15 / #i57457# / [email protected]
+ throw new SQLException(
+
SharedResources.getInstance().getResourceStringWithSubstitution(
+ Resources.STR_UNSUPPORTED_FEATURE, "$featurename$",
"XBlob::positionOfBlob"),
+ this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(), 0,
Any.VOID);
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLBlob.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLCallableStatement.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLCallableStatement.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLCallableStatement.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLCallableStatement.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,340 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import org.apache.openoffice.comp.sdbc.dbtools.util.DBTypeConversion;
+import org.apache.openoffice.comp.sdbc.dbtools.util.Resources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.SharedResources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.io.XInputStream;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XArray;
+import com.sun.star.sdbc.XBlob;
+import com.sun.star.sdbc.XClob;
+import com.sun.star.sdbc.XOutParameters;
+import com.sun.star.sdbc.XRef;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.uno.Any;
+import com.sun.star.util.Date;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.Time;
+
+public class JavaSQLCallableStatement extends JavaSQLPreparedStatement
implements XRow, XOutParameters {
+ public JavaSQLCallableStatement(JavaSQLConnection connection, String sql) {
+ super(connection, sql);
+ }
+
+ @Override
+ protected void createStatement() throws SQLException {
+ checkDisposed();
+ if (jdbcStatement == null) {
+ try {
+ try {
+ jdbcStatement = connection.getJDBCConnection().prepareCall(
+ sqlStatement, resultSetType, resultSetConcurrency);
+ } catch (NoSuchMethodError noSuchMethodError) {
+ jdbcStatement =
connection.getJDBCConnection().prepareCall(sqlStatement);
+ }
+ } catch (java.sql.SQLException sqlException) {
+ throw Tools.toUnoExceptionLogged(this, logger, sqlException);
+ }
+ }
+ }
+
+ // XRow
+
+ public synchronized XInputStream getBinaryStream(int columnIndex) throws
SQLException {
+ createStatement();
+ XBlob blob = getBlob(columnIndex);
+ if (blob != null) {
+ return blob.getBinaryStream();
+ }
+ return null;
+ }
+
+ @Override
+ public XInputStream getCharacterStream(int columnIndex) throws
SQLException {
+ createStatement();
+ XClob clob = getClob(columnIndex);
+ if (clob != null) {
+ return clob.getCharacterStream();
+ }
+ return null;
+ }
+
+ @Override
+ public synchronized boolean getBoolean(int columnIndex) throws
SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getBoolean(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized byte getByte(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getByte(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized byte[] getBytes(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getBytes(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized Date getDate(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ java.sql.Date jdbcDate =
((java.sql.CallableStatement)jdbcStatement).getDate(columnIndex);
+ if (jdbcDate != null) {
+ return DBTypeConversion.toDate(jdbcDate.toString());
+ } else {
+ return null;
+ }
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized double getDouble(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getDouble(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized float getFloat(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getFloat(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized int getInt(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getInt(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized long getLong(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getLong(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized XArray getArray(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ java.sql.Array array =
((java.sql.CallableStatement)jdbcStatement).getArray(columnIndex);
+ if (array != null) {
+ return new JavaSQLArray(logger, array);
+ } else {
+ return null;
+ }
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized XClob getClob(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ java.sql.Clob clob =
((java.sql.CallableStatement)jdbcStatement).getClob(columnIndex);
+ if (clob != null) {
+ return new JavaSQLClob(logger, clob);
+ } else {
+ return null;
+ }
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized XBlob getBlob(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ java.sql.Blob blob =
((java.sql.CallableStatement)jdbcStatement).getBlob(columnIndex);
+ if (blob != null) {
+ return new JavaSQLBlob(logger, blob);
+ } else {
+ return null;
+ }
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized XRef getRef(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ java.sql.Ref ref =
((java.sql.CallableStatement)jdbcStatement).getRef(columnIndex);
+ if (ref != null) {
+ return new JavaSQLRef(ref);
+ } else {
+ return null;
+ }
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized Object getObject(int columnIndex, XNameAccess typeMap)
throws SQLException {
+ createStatement();
+ if (typeMap.hasElements()) {
+ throw new SQLException(
+
SharedResources.getInstance().getResourceStringWithSubstitution(
+ Resources.STR_UNSUPPORTED_FEATURE,
"$featurename$", "Type maps"),
+ this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(),
0, Any.VOID);
+ }
+ try {
+ Object ret = Any.VOID;
+ Object object =
((java.sql.CallableStatement)jdbcStatement).getObject(columnIndex);
+ if (object instanceof String) {
+ ret = (String) object;
+ } else if (object instanceof Boolean) {
+ ret = (Boolean) object;
+ } else if (object instanceof java.sql.Date) {
+ ret =
DBTypeConversion.toDate(((java.sql.Date)object).toString());
+ } else if (object instanceof java.sql.Time) {
+ ret =
DBTypeConversion.toTime(((java.sql.Time)object).toString());
+ } else if (object instanceof java.sql.Timestamp) {
+ ret =
DBTypeConversion.toDateTime(((java.sql.Timestamp)object).toString());
+ }
+ return ret;
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoExceptionLogged(this, logger, exception);
+ }
+ }
+
+ @Override
+ public synchronized short getShort(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getShort(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized String getString(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ return
((java.sql.CallableStatement)jdbcStatement).getString(columnIndex);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized Time getTime(int columnIndex) throws SQLException {
+ createStatement();
+ try {
+ java.sql.Time time =
((java.sql.CallableStatement)jdbcStatement).getTime(columnIndex);
+ if (time != null) {
+ return DBTypeConversion.toTime(time.toString());
+ } else {
+ return new Time();
+ }
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized DateTime getTimestamp(int columnIndex) throws
SQLException {
+ createStatement();
+ try {
+ java.sql.Timestamp timestamp =
((java.sql.CallableStatement)jdbcStatement).getTimestamp(columnIndex);
+ if (timestamp != null) {
+ return DBTypeConversion.toDateTime(timestamp.toString());
+ } else {
+ return new DateTime();
+ }
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public synchronized boolean wasNull() throws SQLException {
+ createStatement();
+ try {
+ return ((java.sql.CallableStatement)jdbcStatement).wasNull();
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ // XOutParameters
+
+ @Override
+ public synchronized void registerOutParameter(int index, int sqlType,
String typeName) throws SQLException {
+ createStatement();
+ try {
+
((java.sql.CallableStatement)jdbcStatement).registerOutParameter(index,
sqlType, typeName);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+
+ @Override
+ public void registerNumericOutParameter(int index, int sqlType, int scale)
throws SQLException {
+ createStatement();
+ try {
+
((java.sql.CallableStatement)jdbcStatement).registerOutParameter(index,
sqlType, scale);
+ } catch (java.sql.SQLException exception) {
+ throw Tools.toUnoException(this, exception);
+ }
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLCallableStatement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLClob.java
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLClob.java?rev=1814552&view=auto
==============================================================================
---
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLClob.java
(added)
+++
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLClob.java
Wed Nov 8 04:17:25 2017
@@ -0,0 +1,109 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ *************************************************************/
+package com.sun.star.comp.sdbc;
+
+import java.io.Reader;
+
+import
org.apache.openoffice.comp.sdbc.dbtools.comphelper.ResourceBasedEventLogger;
+import org.apache.openoffice.comp.sdbc.dbtools.util.Resources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.SharedResources;
+import org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState;
+
+import com.sun.star.io.XInputStream;
+import com.sun.star.lib.uno.adapter.InputStreamToXInputStreamAdapter;
+import com.sun.star.lib.uno.helper.ComponentBase;
+import com.sun.star.logging.LogLevel;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XClob;
+import com.sun.star.uno.Any;
+
+public class JavaSQLClob extends ComponentBase implements XClob {
+ private ResourceBasedEventLogger logger;
+ private java.sql.Clob jdbcClob;
+
+ public JavaSQLClob(ResourceBasedEventLogger logger, java.sql.Clob
jdbcClob) {
+ this.logger = logger;
+ this.jdbcClob = jdbcClob;
+ }
+
+ @Override
+ protected void postDisposing() {
+ try {
+ jdbcClob.free();
+ } catch (java.sql.SQLException jdbcSQLException) {
+ logger.log(LogLevel.WARNING, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public XInputStream getCharacterStream() throws SQLException {
+ try {
+ Reader reader = jdbcClob.getCharacterStream();
+ if (reader != null) {
+ return new InputStreamToXInputStreamAdapter(new
ReaderInputStream(reader));
+ } else {
+ return null;
+ }
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public String getSubString(long pos, int length) throws SQLException {
+ try {
+ return jdbcClob.getSubString(pos, length);
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public long length() throws SQLException {
+ try {
+ return jdbcClob.length();
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public long position(String searchstr, int start) throws SQLException {
+ try {
+ return jdbcClob.position(searchstr, start);
+ } catch (java.sql.SQLException jdbcSQLException) {
+ throw Tools.toUnoException(this, jdbcSQLException);
+ }
+ }
+
+ @Override
+ public long positionOfClob(XClob arg0, long arg1) throws SQLException {
+ // this was put here in CWS warnings01. The previous implementation
was defective, as it did ignore
+ // the pattern parameter. Since the effort for proper implementation
is rather high - we would need
+ // to translated patter into a byte[] -, we defer this functionality
for the moment (hey, it was
+ // unusable, anyway)
+ // 2005-11-15 / #i57457# / [email protected]
+ throw new SQLException(
+
SharedResources.getInstance().getResourceStringWithSubstitution(
+ Resources.STR_UNSUPPORTED_FEATURE, "$featurename$",
"XClob::positionOfClob"),
+ this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(), 0,
Any.VOID);
+ }
+}
Propchange:
openoffice/trunk/main/connectivity/java/sdbc_jdbc/src/com/sun/star/comp/sdbc/JavaSQLClob.java
------------------------------------------------------------------------------
svn:eol-style = native