geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [geode] 02/02: read now checks if jdbc connection and mapping exist
Date Tue, 02 Jan 2018 19:21:13 GMT
This is an automated email from the ASF dual-hosted git repository.

dschneider pushed a commit to branch feature/GEODE-4009
in repository https://gitbox.apache.org/repos/asf/geode.git

commit ac7ddc3a34f46927810fad51b064a6cb36c9f6ee
Author: Darrel Schneider <dschneider@pivotal.io>
AuthorDate: Tue Jan 2 11:20:38 2018 -0800

    read now checks if jdbc connection and mapping exist
---
 .../geode/connectors/jdbc/internal/SqlHandler.java | 25 +++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlHandler.java
b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlHandler.java
index 8479217..b728226 100644
--- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlHandler.java
+++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlHandler.java
@@ -86,11 +86,22 @@ public class SqlHandler {
   }
 
   private RegionMapping getMappingForRegion(String regionName) {
-    return this.configService.getMappingForRegion(regionName);
+    RegionMapping regionMapping = this.configService.getMappingForRegion(regionName);
+    if (regionMapping == null) {
+      throw new IllegalStateException("JDBC mapping for region " + regionName
+          + " not found. Create the mapping with the gfsh command 'create jdbc-mapping'.");
+    }
+    return regionMapping;
   }
 
   private ConnectionConfiguration getConnectionConfig(String connectionConfigName) {
-    return this.configService.getConnectionConfig(connectionConfigName);
+    ConnectionConfiguration connectionConfig =
+        this.configService.getConnectionConfig(connectionConfigName);
+    if (connectionConfig == null) {
+      throw new IllegalStateException("JDBC connection with name " + connectionConfigName
+          + " not found. Create the connection with the gfsh command 'create jdbc-connection'");
+    }
+    return connectionConfig;
   }
 
   private String getKeyColumnName(Connection connection, String tableName) {
@@ -160,18 +171,8 @@ public class SqlHandler {
       throw new IllegalArgumentException("PdxInstance cannot be null for non-destroy operations");
     }
     RegionMapping regionMapping = getMappingForRegion(region.getName());
-    if (regionMapping == null) {
-      throw new IllegalStateException(
-          "JDBC write failed. JDBC mapping for region " + region.getFullPath()
-              + " not found. Create the mapping with the gfsh command 'create jdbc-mapping'.");
-    }
     ConnectionConfiguration connectionConfig =
         getConnectionConfig(regionMapping.getConnectionConfigName());
-    if (connectionConfig == null) {
-      throw new IllegalStateException(
-          "JDBC write failed. JDBC connection with name " + regionMapping.getConnectionConfigName()
-              + " not found. Create the connection with the gfsh command 'create jdbc-connection'");
-    }
 
     String tableName = regionMapping.getRegionToTableName();
     int pdxTypeId = value == null ? 0 : ((PdxInstanceImpl) value).getPdxType().getTypeId();

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <commits@geode.apache.org>.

Mime
View raw message