+ Reply to Thread
Results 1 to 3 of 3

Thread: What is wrong in logineventhandler code

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What is wrong in logineventhandler code

    Hi everyone can you helpme? what is the wrong in this code can you explain me.
    thanks for all.

    Code:
    import com.electrotank.electroserver4.extensions.ChainAction;
    import com.electrotank.electroserver4.extensions.BaseLoginEventHandler;
    import com.electrotank.electroserver4.extensions.LoginContext;
    import com.electrotank.electroserver4.extensions.api.value.EsObject;
    import com.electrotank.electroserver4.extensions.api.value.EsObjectRO;
    import com.electrotank.electroserver4.examples.database.DatabasePlugin;
    /**
     *
     * @author kadorek
     */
    public class LoginEventHandler extends BaseLoginEventHandler {
        private String username;
        private DatabasePlugin dbtPlg=(DatabasePlugin) getApi().getServerPlugin("DatabasePlugin");
        private String poolname="mysqlpool";
        private String query;
        private EsObject esobj ;
       
    
        @Override
        public ChainAction executeLogin(LoginContext icerik){
           username=icerik.getUserName();
           System.out.println(username+" isimli kullaniici sorgulaniyor.");
           if(checkuser(username)){
                return ChainAction.Fail;
           }else{
                return ChainAction.OkAndContinue;
           }
          }
    
        private Boolean checkuser(String name){
            name="'"+name+"'";
            this.query="Select username,password from member where username="+name;
            this.esobj=dbtPlg.doQuery(this.query);
            if(this.validateAndReturnEsObjectEntry(this.esobj, "username","string")!=""){
                return Boolean.TRUE;
            }else{
                return Boolean.FALSE;
            }
        }
        
        private Object validateAndReturnEsObjectEntry(EsObjectRO esObject, String parmName, String parmType) {
            Object results = null;
            if(!esObject.variableExists(parmName)) {
                throw new RuntimeException("The '" + parmName + "' " + parmType + " variable was not defined - it is required!");
            } else {
                results = esObject.getRawVariable(parmName);
            }
            return results;
        }
     
    }

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,214
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    What kind of error message are you getting?
    Do you have your Extension.xml set up correctly so that the database is being queried?
    Did you remember to make this a server level component?

    I suggest that you add a lot of logging lines so that you can tell where things die.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Junior Member
    Join Date
    Feb 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks terressa.i solved the problem .

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts