From 06eaf7232e9a920468c0f8d74dcf2fe8b555501c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:24:36 +0200 Subject: Adding upstream version 1:10.11.6. Signed-off-by: Daniel Baumann --- storage/connect/ApacheInterface.java | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 storage/connect/ApacheInterface.java (limited to 'storage/connect/ApacheInterface.java') diff --git a/storage/connect/ApacheInterface.java b/storage/connect/ApacheInterface.java new file mode 100644 index 00000000..47b46dc0 --- /dev/null +++ b/storage/connect/ApacheInterface.java @@ -0,0 +1,61 @@ +package wrappers; + +import java.sql.*; +import java.util.Hashtable; +import org.apache.commons.dbcp2.BasicDataSource; + +public class ApacheInterface extends JdbcInterface { + static Hashtable pool = new Hashtable(); + + public ApacheInterface() { + this(true); + } // end of default constructor + + public ApacheInterface(boolean b) { + super(b); + } // end of constructor + + @Override + public int JdbcConnect(String[] parms, int fsize, boolean scrollable) { + int rc = 0; + String url = parms[1]; + BasicDataSource ds = null; + + if (DEBUG) + System.out.println("Connecting to Apache data source"); + + try { + CheckURL(url, null); + + if ((ds = pool.get(url)) == null) { + ds = new BasicDataSource(); + ds.setDriverClassName(parms[0]); + ds.setUrl(url); + ds.setUsername(parms[2]); + ds.setPassword(parms[3]); + pool.put(url, ds); + } // endif ds + + // if (parms.length > 4 && parms[4] != null) + // ds.setConnectionProperties(parms[4]); + + // Get a connection from the data source + conn = ds.getConnection(); + + // Get the data base meta data object + dbmd = conn.getMetaData(); + + // Get a statement from the connection + stmt = GetStmt(fsize, scrollable); + } catch (SQLException se) { + SetErrmsg(se); + rc = -2; + } catch (Exception e) { + SetErrmsg(e); + rc = -3; + } // end try/catch + + return rc; + } // end of JdbcConnect + +} // end of class ApacheInterface -- cgit v1.2.3