This is an automated email from the ASF dual-hosted git repository. agingade pushed a commit to branch feature/GEODE-3781 in repository https://gitbox.apache.org/repos/asf/geode.git
commit eae6c079562b56fec8c362d346afbafdd8676d2b Author: Anil <[email protected]> AuthorDate: Wed Oct 25 16:15:53 2017 -0700 implemented getConnection --- .../apache/geode/connectors/jdbc/JDBCManager.java | 35 +++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java index ed8bcd9..7c0283c 100644 --- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java +++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java @@ -44,12 +44,6 @@ public class JDBCManager { this.config = config; } - private void establishConnection() { - // Class.forName(this.config.getDriver()); - // conn = DriverManager.getConnection(this.config.getURL()); - // stmt = conn.createStatement(); - } - public class ColumnValue { final private boolean isKey; @@ -144,7 +138,34 @@ public class JDBCManager { } private Connection getConnection() { - return null; // NYI + Connection result = this.conn; + try { + if (result != null && !result.isClosed()) { + return result; + } + } + catch (SQLException ignore) { + // If isClosed throws fall through and connect again + } + + if (result == null) { + try { + Class.forName(this.config.getDriver()); + } + catch (ClassNotFoundException e) { + // TODO: consider a different exception + throw new IllegalStateException("Driver class " + this.config.getDriver() + " not found", e); + } + } + try { + result = DriverManager.getConnection(this.config.getURL()); + } + catch (SQLException e) { + // TODO: consider a different exception + throw new IllegalStateException("Could not connect to " + this.config.getURL(), e); + } + this.conn = result; + return result; } // private final ConcurrentMap<String, PreparedStatement> preparedStatementCache = new -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
