Java based connectivity drivers
Michael Stahl
mstahl at redhat.com
Fri Jan 13 14:09:45 UTC 2017
On 13/01/17 13:44, Bunth Tamás wrote:
> Hi,
>
> I'd like to have a better understanding of how the hsqldb and jdbc drivers work.
>
> Is there any wiki page for them like "FirebirdSQL" for firebird that I
> couldn't find?
maybe there's some old page somewhere here
http://www.openoffice.org/dba/
https://wiki.openoffice.org/wiki/Category:Database
> The code in connectivity/source/drivers/jdbc contains a bunch of java
> function calls afais. So where are the java codes, and how does the
> driver call them?
it looks like the jdbc driver uses JNI to call Java methods directly
from C++.
like this, the strings are method name and signature:
jobject out =
callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/DatabaseMetaData;", mID)
i think there's some generic JDBC implementation in the JRE plus a
driver-specific part in the JDBC driver.
so for the hsqldb case, i would expect this to call into here:
workdir/UnpackedTarball/hsqldb/src/org/hsqldb/jdbc/jdbcConnection.java:
public synchronized DatabaseMetaData getMetaData() throws SQLException {
another point is that we have (at least on Linux) segregated the JDBC
driver into a separate thread for performance reasons, as it turned out
that JNI calls on the main thread happen to be really slow.
see jdbc.component:
environment="@CPPU_ENV@:affine" prefix="jdbc"
this means that every UNO call first goes via the affine UNO-UNO bridge
onto a separate thread into the C++ JDBC UNO component, then that calls
via JNI into the Java library, then the return value of that is
converted with some C++ UNO wrapper, then it goes back over the bridge
to the calling thread.
More information about the LibreOffice
mailing list