private void afterOverlay(DataHandler dataHandler, IDatabaseType database) { XulTextbox portBox = (XulTextbox) document.getElementById("port-number-text"); // $NON-NLS-1$ Object data = dataHandler.getData(); String portValue = null; IDatabaseConnection databaseConnection = null; // Extract the stored value for port number in the model if (data instanceof IDatabaseConnection) { databaseConnection = (IDatabaseConnection) data; portValue = databaseConnection.getDatabasePort(); } if (portBox != null) { // If the model has the port number use it other wise use the default one for the selected // database int port = (portValue != null && portValue.length() > 0) ? Integer.parseInt(portValue) : database.getDefaultDatabasePort(); if (port > 0) { portBox.setValue(Integer.toString(port)); } } if (dataHandler != null) { dataHandler.popCache(); } GwtGroupBox box1 = (GwtGroupBox) document.getElementById("database-options-box"); XulHbox box = (XulHbox) document.getElementById("connection-access-list-box"); box1.layout(); ((GwtHbox) box).layout(); }
@Override public String getURL(IDatabaseConnection connection) throws DatabaseDialectException { if (connection.getAccessType() == DatabaseAccessType.ODBC) { return "jdbc:odbc:" + connection.getDatabaseName(); } else { return getNativeJdbcPre() + connection.getHostname() + ":" + connection.getDatabasePort() + "/" + connection.getDatabaseName(); } }
@Override public String getURL(IDatabaseConnection connection) throws DatabaseDialectException { // jdbc:informix-sqli://192.168.149.128:9088/stores:INFORMIXSERVER=demo_on if (connection.getAccessType() == DatabaseAccessType.ODBC) { return "jdbc:odbc:" + connection.getDatabaseName(); } else { return "jdbc:informix-sqli://" + connection.getHostname() + ":" + connection.getDatabasePort() + "/" + connection.getDatabaseName() + ":INFORMIXSERVER=" + connection.getInformixServername() + ";DELIMIDENT=Y"; } }
@VisibleForTesting protected boolean isPortUsedByServer(IDatabaseConnection databaseConnection) { // get connection IP address String connectionHostName = databaseConnection.getHostname(); InetAddress connectionAddress = null; try { connectionAddress = getAdressFromString(connectionHostName); } catch (UnknownHostException e) { Logger.warn( this, Messages.getInstance() .getErrorString( "DatasourceSystemListener.WARN_0001_UNABLE_TO_GET_CONNECTION_ADDRESS"), e); //$NON-NLS-1$ return false; } // get connection port String stringConnectionPort = databaseConnection.getDatabasePort(); // get server URL String fullyQualifiedServerURL = PentahoSystem.getApplicationContext().getFullyQualifiedServerURL(); URL url = null; try { url = new URL(fullyQualifiedServerURL); } catch (MalformedURLException e) { Logger.warn( this, Messages.getInstance() .getErrorString("DatasourceSystemListener.WARN_0002_UNABLE_TO_PARSE_SERVER_URL"), e); //$NON-NLS-1$ return false; } // get server IP address String hostNameUsedByServer = url.getHost(); InetAddress serverAddress = null; try { serverAddress = getAdressFromString(hostNameUsedByServer); } catch (UnknownHostException e) { Logger.warn( this, Messages.getInstance() .getErrorString("DatasourceSystemListener.WARN_0003_UNABLE_TO_GET_SERVER_ADDRESS"), e); //$NON-NLS-1$ return false; } // get server port int portUsedByServer = url.getPort(); boolean isAddressesEquals = connectionAddress.equals(serverAddress); boolean isPortsEquals = false; try { Integer connectionPort = Integer.valueOf(stringConnectionPort); isPortsEquals = connectionPort.equals(portUsedByServer); } catch (NumberFormatException e) { Logger.warn( this, Messages.getInstance() .getErrorString("DatasourceSystemListener.WARN_0004_UNABLE_TO_GET_PORT_NUMBER"), e); //$NON-NLS-1$ return false; } return isAddressesEquals && isPortsEquals; }