Home » Developer & Programmer » JDeveloper, Java & XML » OracleFailoverEventHandler vs OracleHAEventHandler (Oracle 11.1.0.7 ODAC Client, window server 2003 )
OracleFailoverEventHandler vs OracleHAEventHandler [message #472432] Fri, 20 August 2010 09:14
hemss007
Messages: 21
Registered: June 2008
Location: LONDON
Junior Member
Hello There !
I have recently Implemented Oracle 11gR2 RAC Two node environment in our organization.

Now I am confused about both this term.I dont understand what would I use for my TAF CALLBACK HIGHLY AVAIBILITY.

I have gone through documentation as well but still not cleared my concept.

here is bit part of my code !!
    
		/**********************************************************************
		 * This method is FailOver Callback method called when the 
		 * connection to the database is severed. It is called several 
		 * times in the process of re-establishing connection to the 
		 * same or standby database.
		 **********************************************************************/ 
		public FailoverReturnCode OnFailover(object sender, OracleFailoverEventArgs eventArgs)
		{
		// check the Failover event that occurred and display appropriate message
		switch(eventArgs.FailoverEvent)
		{
            // when failover begins
			case FailoverEvent.Begin:
			{
				MessageBox.Show("Callback method called :Failover Begin");
				lblStatus.Text="Callback method called :Failover Begin. Trying to reconnect, Please wait...";
			
			    break;
			}
            // when failover is aborted
			case FailoverEvent.Abort:
			{	
				MessageBox.Show("Callback method called :Failover Aborted");
                lblStatus.Text="Callback method called :Failover Aborted";
				break;
			}
            // when failover is complete
			case FailoverEvent.End:
			{
				MessageBox.Show("Callback method called :Failover End");
                
				// call method to set session information on re-established
				// connection
				alterSessionInfo();
				lblStatus.Text="Callback method called :Failover End";
				break;
			}
            //when error occurs while reconnecting
			case FailoverEvent.Error:
			{
				lblStatus.Text="Failover Error -Sleeping and Retrying to connect to database. Please wait... ";
			    
				//check to do form Refresh only once
				if(doRefresh==0)
					this.Refresh();
				doRefresh=1;
				return FailoverReturnCode.Retry;
			}
            // when reautentication is required during Failover 
			case FailoverEvent.Reauth:
			{
				MessageBox.Show("Callback method called :Failover reauthenticating");
				lblStatus.Text="Callback method called :Failover reauthenticating";
				break;
			}
			default:
			{				
				MessageBox.Show("Bad Failover");
				lblStatus.Text="Bad Failover";
				break;
			}
		}
		return FailoverReturnCode.Success;
		}

	   /*******************************************************************
	   * The purpose of this method is to get the database connection 
	   * using the parameters given in ConnectionParams.cs.
	   * The connection parameter enlist is set to false for the TAF to
	   * work properly.
	   * Note: Replace the datasource parameter with your datasource value
	   * in ConnectionParams.cs file.
	   ********************************************************************/
		private Boolean getDBConnection()
		{
			try
			{
				lblStatus.Text="Connecting to database";
				//Connection Information        
				string connectionString = 
                                        
					//username
					"User Id=" + ConnectionParams.Username +

					//password
					";Password=" + ConnectionParams.Password +
         
					//set enlist parameter to false. Required for TAF
					";enlist=false" +

					//replace with your datasource value (TNSnames)
					";Data Source=" + ConnectionParams.Datasource;
					

                                        
				//Connection to datasource, using connection parameters given above
				conn = new OracleConnection(connectionString);
                
				//Open database connection
				conn.Open();

				lblStatus.Text="Connected to the database. Click 'Get Products Data' to fetch products data ";
			    
				// alter date format for the session 
				this.alterSessionInfo();
				conn.Failover += new OracleFailoverEventHandler(OnFailover);
				
				return true;
			}
				// catch exception when error in connecting to database occurs
			catch (Exception ex) 
			{
				//Display error message
				MessageBox.Show(ex.ToString());
				return false;
			}
		}

Can anybody explain me more or send me link which give me whole idea about Failover vs HA in ODAC.

Many THanks !
Hemesh.
Previous Topic: ORA-29532 when using Callablestatement.execute()
Next Topic: How to map java objects to Oracle datatypes
Goto Forum:
  


Current Time: Thu Mar 28 21:14:52 CDT 2024