src/java/org/apache/cassandra/cli/CliClient.java
// process a statement of the form: connect hostname/port
process a statement of the form: connect hostname/port
process a statement of the form : connect hostname / port
private void executeConnect(Tree statement)
    {
        Tree idList = statement.getChild(0);
        int portNumber = Integer.parseInt(statement.getChild(1).getText());
        StringBuilder hostName = new StringBuilder();
        int idCount = idList.getChildCount();
        for (int idx = 0; idx < idCount; idx++)
        {
            hostName.append(idList.getChild(idx).getText());
        }
        CliMain.disconnect();
        sessionState.hostName = hostName.toString();
        sessionState.thriftPort = portNumber;
        if (statement.getChildCount() == 4)
        {
            sessionState.username = statement.getChild(2).getText();
            sessionState.password = CliUtils.unescapeSQLString(statement.getChild(3).getText());
        }
        CliMain.connect(sessionState.hostName, sessionState.thriftPort);
    }
private void executeConnect ( Tree statement ) { Tree idList = statement . getChild ( 0 ) ; int portNumber = Integer . parseInt ( statement . getChild ( 1 ) . getText ( ) ) ; StringBuilder hostName = new StringBuilder ( ) ; int idCount = idList . getChildCount ( ) ; for ( int idx = 0 ; idx < idCount ; idx ++ ) { hostName . append ( idList . getChild ( idx ) . getText ( ) ) ; } CliMain . disconnect ( ) ; sessionState . hostName = hostName . toString ( ) ; sessionState . thriftPort = portNumber ; if ( statement . getChildCount ( ) == 4 ) { sessionState . username = statement . getChild ( 2 ) . getText ( ) ; sessionState . password = CliUtils . unescapeSQLString ( statement . getChild ( 3 ) . getText ( ) ) ; } CliMain . connect ( sessionState . hostName , sessionState . thriftPort ) ; }
process a statement of the form: connect hostname/port
process a statement of the form : connect hostname / port
// disconnect current connection, if any. // This is a no-op, if you aren't currently connected. // now, connect to the newly specified host name and port // if we have user name and password