Class Connector

  • All Implemented Interfaces:
    TreeUnit, Unit, java.lang.Comparable<AbstractUnit>

    public final class Connector
    extends AbstractUnit
    Stores all parameters for a connection to database. The effective connection is a different object.
    • Constructor Detail

      • Connector

        public Connector​(Project project)
        Connector always belongs to a project
        Parameters:
        project - owner
      • Connector

        public Connector​(Project project,
                         java.lang.String alias,
                         java.lang.String rdbmsName,
                         com.wisecoders.dbs.rdbms.driver.model.DriverJarClass driverJarClass,
                         java.lang.String host,
                         int port,
                         java.lang.String dbInstance,
                         java.lang.String userName,
                         boolean readOnly)
        Connector with parameters
        Parameters:
        project - owner
        alias - identifies this connector in project
        rdbmsName - the database name
        driverJarClass - the database driver
        host - host to connect to
        port - port to connect to
        dbInstance - the name of the database or the instance
        userName - of the database user
        readOnly - true to read only
    • Method Detail

      • addSqlEvent

        public void addSqlEvent​(com.wisecoders.dbs.rdbms.connect.model.SqlEvent event)
      • startEnvoy

        public com.wisecoders.dbs.rdbms.connect.model.envoy.Envoy startEnvoy​(java.lang.String envoyName)
      • getUserName

        public java.lang.String getUserName()
      • setUser

        public boolean setUser​(java.lang.String user)
      • getPassword

        public java.lang.String getPassword()
      • setPassword

        public boolean setPassword​(java.lang.String password)
        Set the password for the database user
        Parameters:
        password - to use
        Returns:
        true if password changed
      • setParam

        public boolean setParam​(java.lang.String param)
      • setParam2

        public boolean setParam2​(java.lang.String param2)
      • getParameter

        public java.lang.String getParameter()
      • getParameter2

        public java.lang.String getParameter2()
      • getHost

        public java.lang.String getHost()
      • setHost

        public boolean setHost​(java.lang.String host)
        Set the host to connect to
        Parameters:
        host - to connect to
        Returns:
        true if changed
      • getPort

        public int getPort()
      • setPort

        public boolean setPort​(int port)
        Set the port to connect to
        Parameters:
        port - on database host
        Returns:
        true if changed
      • isLocalhost

        public boolean isLocalhost()
        Returns:
        true if the host is the localhost
      • isLocalhostAndDefaultPort

        public boolean isLocalhostAndDefaultPort()
      • setRdbms

        public boolean setRdbms​(java.lang.String rdbms)
      • getRdbms

        public java.lang.String getRdbms()
      • setCatalog

        public void setCatalog​(java.lang.String catalog)
      • getCatalog

        public java.lang.String getCatalog()
      • getInstance

        public java.lang.String getInstance()
      • setDriverIndexInList

        public boolean setDriverIndexInList​(int position)
      • getDriverIndexInList

        public int getDriverIndexInList()
      • setInstance

        public boolean setInstance​(java.lang.String instance)
      • closeAllEnvoysAndSsh

        public void closeAllEnvoysAndSsh()
      • setReadOnly

        public boolean setReadOnly​(boolean readOnly)
      • isReadOnly

        public boolean isReadOnly()
      • getStatusString

        public java.lang.String getStatusString()
      • getPhysicalConnectedCount

        public int getPhysicalConnectedCount()
      • isProcessing

        public boolean isProcessing()
      • setRememberPassword

        public boolean setRememberPassword​(boolean remember)
      • isRememberPassword

        public boolean isRememberPassword()
      • setJdbcDriver

        public boolean setJdbcDriver​(com.wisecoders.dbs.rdbms.driver.model.DriverJarClass driver)
      • getDriverJarClass

        public com.wisecoders.dbs.rdbms.driver.model.DriverJarClass getDriverJarClass()
      • needsEdit

        public boolean needsEdit()
        Returns:
        true if cannot connect until a password is given
      • getProperties

        public java.util.Properties getProperties()
      • getURL

        public java.lang.String getURL()
      • getURLHidePassword

        public java.lang.String getURLHidePassword​(boolean hidePassword)
      • stopEnvoysWithTrack

        public void stopEnvoysWithTrack​(com.wisecoders.dbs.rdbms.connect.model.SqlEvent track)
      • getHTMLMessageAndAdvice

        public java.lang.String getHTMLMessageAndAdvice​(java.lang.Throwable ex,
                                                        ConnectivityTip tip)
      • getHTMLMessageAndAdvice

        public java.lang.String getHTMLMessageAndAdvice​(java.lang.Throwable ex,
                                                        java.lang.String title,
                                                        java.lang.String message,
                                                        ConnectivityTip tip)
      • getPlainMessageAndAdvice

        public java.lang.String getPlainMessageAndAdvice​(java.lang.Throwable ex)
      • setCustomUrl

        public boolean setCustomUrl​(java.lang.String customUrl)
      • getCustomUrl

        public java.lang.String getCustomUrl()
      • getSavedAliases

        public static java.util.List<java.lang.String> getSavedAliases()
      • saveInHistory

        public void saveInHistory()
      • getHostForAlias

        public static java.lang.String getHostForAlias​(java.lang.String alias)
      • getRdbmsForAlias

        public static java.lang.String getRdbmsForAlias​(java.lang.String alias)
      • dropAlias

        public static void dropAlias​(java.lang.String alias)
      • renameAlias

        public static void renameAlias​(java.lang.String alias,
                                       java.lang.String newAlias)
      • loadFromHistoryForRdbms

        public void loadFromHistoryForRdbms​(java.lang.String rdbms)
      • loadFromHistoryForAlias

        public void loadFromHistoryForAlias​(java.lang.String alias)
      • learnRdbmsIfRequired

        public void learnRdbmsIfRequired()
      • learnRdbmsTemplate

        public void learnRdbmsTemplate()
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setOnline

        public void setOnline​(boolean isOnline)
      • setHasConnected

        public void setHasConnected()
      • isOnline

        public boolean isOnline()
      • shouldResync

        public boolean shouldResync()
      • resetResyncFlag

        public void resetResyncFlag()
      • getSshHost

        public java.lang.String getSshHost()
      • setSshHost

        public void setSshHost​(java.lang.String sshHost)
      • getSshUser

        public java.lang.String getSshUser()
      • setSshUser

        public void setSshUser​(java.lang.String sshUser)
      • getSshPassword

        public java.lang.String getSshPassword()
      • setSshPassword

        public void setSshPassword​(java.lang.String sshPassword)
      • getSshPublicKeyFile

        public java.lang.String getSshPublicKeyFile()
      • setSshPublicKeyFile

        public void setSshPublicKeyFile​(java.lang.String sshPublicKeyFile)
      • getSshPassphrase

        public java.lang.String getSshPassphrase()
      • setSshPassphrase

        public void setSshPassphrase​(java.lang.String sshPassphrase)
      • getSshPort

        public int getSshPort()
      • setSshPort

        public void setSshPort​(int sshPort)
      • isSshEnable

        public boolean isSshEnable()
      • setSshEnable

        public void setSshEnable​(boolean sshEnable)
      • isSshUseKey

        public boolean isSshUseKey()
      • setSshUseKey

        public void setSshUseKey​(boolean sshUseKey)
      • setupSSHTunnel

        public com.jcraft.jsch.Session setupSSHTunnel​(boolean reuse)
                                               throws com.jcraft.jsch.JSchException,
                                                      java.io.IOException
        Throws:
        com.jcraft.jsch.JSchException
        java.io.IOException
      • pingSSHTunnel

        public com.jcraft.jsch.Session pingSSHTunnel()
                                              throws com.jcraft.jsch.JSchException
        Throws:
        com.jcraft.jsch.JSchException
      • schemaChanged

        public void schemaChanged()
      • getSqlEvents

        public java.util.List<com.wisecoders.dbs.rdbms.connect.model.SqlEvent> getSqlEvents()
      • clearSqlEvents

        public void clearSqlEvents()
      • importSchema

        public Schema importSchema​(java.lang.String schemaName)
                            throws java.lang.Exception
        Reverse engineer given schema from database. METHOD EXPOSED FOR GROOVY.
        Parameters:
        schemaName - to reverse engineer.
        Returns:
        imported schema
        Throws:
        java.lang.Exception - during exception
      • isMongo

        public boolean isMongo()
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
      • getTimeZone

        public java.lang.String getTimeZone()
      • setTimeZone

        public boolean setTimeZone​(java.lang.String timeZone)