From 186d71644a15886cb49bef69a606883fb715141b Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Wed, 10 Apr 2024 09:52:06 +0200 Subject: [PATCH] JDBC Shim --- Doc/DbDevel/dbDevel.xml | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Doc/DbDevel/dbDevel.xml b/Doc/DbDevel/dbDevel.xml index 2be5f5eb1..ea381059f 100644 --- a/Doc/DbDevel/dbDevel.xml +++ b/Doc/DbDevel/dbDevel.xml @@ -4996,6 +4996,67 @@ if (resultSet.wasNull()) { </section> </section> + <section xml:id="sda1_jdbc_sect_driverDynLoad"> + <title>Dynamically load a <xref linkend="glo_JDBC"/> driver</title> + + <figure xml:id="sda1_jdbc_fig_dynamicLoadProblem"> + <title>Problem: Dynamic driver configuration</title> + + <informaltable border="0"> + <colgroup width="50%"/> + + <colgroup width="50%"/> + + <tr> + <td valign="top"><screen>server=db.somedomain.org +port=3306 +... +driver=mariadb-java-client-3.3.3.jar</screen></td> + + <td valign="top"><itemizedlist> + <listitem> + <para>Driver file + <filename>mariadb-java-client-3.3.3.jar</filename> shall + be loaded at runtime.</para> + </listitem> + + <listitem> + <para>Cannot be packaged by manufacturer.</para> + </listitem> + + <listitem> + <para>Problem: <link + xlink:href="https://stackoverflow.com/questions/60764/how-to-load-jar-files-dynamically-at-runtime">Class + loader and security</link></para> + </listitem> + </itemizedlist></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="sda1_jdbc_fig_jdbcShimDriver"> + <title>Shim driver (facade)</title> + + <programlisting language="java">import java.sql.Driver; + ... +public class DriverShim implements Driver { + private Driver driver; + DriverShim(Driver driver) { + this.driver = driver; + } + @Override + public Connection connect(String s, Properties properties) throws SQLException { + return driver.connect(s, properties); + } + @Override + public boolean acceptsURL(String u) throws SQLException { + return driver.acceptsURL(u); + } +... +}</programlisting> + </figure> + </section> + <section xml:id="sda1_jdbc_sect_surrogateKeys"> <title>Handling surrogate keys</title> -- GitLab