Search code examples
hanageoservergeotoolssap-cloud-platform

Taking a wrong port (30015) number in geoserver when I try to create datastore,Database SAP HANA CLOUD


Geo-server taking the wrong port number when I try to create the datastore, because of that I'm not able to create the store. The data base is sap Hana cloud .

From SAP Hana cloud I'm launching the geoserver 2.14 . In geoserver war I added gt-jdbc-hana-21.0.jar ( which is provided by the geotool ) and **ngdbc.jar **.

From the cloud, I launched the geoserver and then I created the workspace. Then I try to create the datastore. I filled all the fields which are required. But the port number I'm giving 30047( my hana cloud port number ) but it's trying to connect port number 30015 which not there. Because of that, I'm not able to create the data store, please anyone help what is the issue and how to resolve it.

Error message I'm getting

Error creating data store, check the parameters. 
Error message: Unable to obtain connection: 
Cannot create PoolableConnectionFactory (SAP DBTech JDBC: Cannot connect to jdbc:sap://vadbi1l.nwtrial.od.sap.biz// [Cannot connect to host vadbi1l.nwtrial.od.sap.biz:30015 [Connection refused (Connection refused) (local port 58788 to address 0.0.0.0, remote port 30015 to address 10.117.96.92 (vadbi1l.nwtrial.od.sap.biz))], -813.].)

enter image description here

Hana database with port number enter image description here enter image description here

enter image description here

enter image description here

Geoserver log


Solution

  • Download gt-jdbc-hana-21.0 source code from mvnrepository change code in following class

    In HanaDataStoreFactory class change the getJDBCUrl method

         @SuppressWarnings({"rawtypes", "unchecked"})
            @Override
            protected String getJDBCUrl(Map params) throws IOException {
                        String host = (String) HOST.lookUp(params);
                        int instance = (Integer) INSTANCE.lookUp(params);
                        String database = (String) DATABASE.lookUp(params);
                  Integer port = (Integer) PORT.lookUp(params);
                       HanaConnectionParameters cp = new HanaConnectionParameters(host, instance,
                 database,port);
                     return cp.buildUrl();
        } 
    

    In HanaConnectionParameters class

    /*
     *    GeoTools - The Open Source Java GIS Toolkit
     *    http://geotools.org
     *
     *    (C) 2018, Open Source Geospatial Foundation (OSGeo)
     *
     *    This library is free software; you can redistribute it and/or
     *    modify it under the terms of the GNU Lesser General Public
     *    License as published by the Free Software Foundation;
     *    version 2.1 of the License.
     *
     *    This library is distributed in the hope that it will be useful,
     *    but WITHOUT ANY WARRANTY; without even the implied warranty of
     *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     *    Lesser General Public License for more details.
     */
    package org.geotools.data.hana;
    
    /**
     * SAP HANA connection parameters.
     *
     * @author Stefan Uhrig, SAP SE
     */
    public class HanaConnectionParameters {
    
        /**
         * SAP HANA connection parameters constructor.
         *
         * @param host The database host.
         * @param instance The database instance.
         * @param database The name of the tenant database. Set to null or empty string if the database
         *     is a single-container system. Set to SYSTEMDB to connect to the system database of a
         *     multi-container system.
         */
        public HanaConnectionParameters(String host, int instance, String database,int port) {
            super();
            this.host = host;
            this.instance = instance;
            this.database = database;
            this.port = port;
        }
    
        private String host;
    
        private Integer  instance;
    
        private String database;
    
        private Integer port;
    
        public String getHost() {
            return host;
        }
    
        public Integer getInstance() {
            return instance;
        }
    
        public String getDatabase() {
            return database;
        }
    
        public Integer getPort() {
            return this.port;
        }
        /**
         * Builds a JDBC connection URL.
         *
         * @return Returns the JDBC connection URL corresponding to these parameters.
         */
        public String buildUrl() {
    
             String url = "jdbc:sap://" + this.host + ":" + this.port;
             return url;
    
        }
    }
    

    after changing in the respective class , copy the pom content from gt-jdbc-hana-21.0 . build your maven and take the jar .