Search the Blog

Sunday, August 18, 2019

JAVA program to return product of array element

Implement a function in JAVA of given array of integers, returns a new array for which every index carries the value of the product of the remaining elements.



Given array [2,3,1,4,5] it would return [60,40,120,30,24]


JAVA program to return product of array element



public class Main {

   List<Integer> arrInput1[];
   static  List<Integer> arrOutput1[];
   static int n;
   public static void main(String[] ar)
   {
   System.out.println("Enter the array size");
   Scanner a_dizsweb= new Scanner(System.in);
   n=a_dizsweb.nextInt();
   ArrayList<Integer> arrInput1=new ArrayList<Integer>();
   ArrayList<Integer>    arrOutput1=new ArrayList<Integer>();
     System.out.println("Enter the array size  ");

    for (int i=0;i<n;i++)
    {
          arrInput1.add(i, new Scanner(System.in).nextInt());
    }

findSpecialProduct(arrInput1);

    }
    public static void findSpecialProduct(List<Integer> inputArray) {
   ArrayList<Integer> arrOutput1=new ArrayList<Integer>();
         for(int k=0; k<n;k++)
      {
          int indexvalue1=1;
          int index=k;
       for (int i =0; i<n;i++)
       {
           if (index==i)
           {
             indexvalue1=indexvalue1*1;
           }
           else
           {
            indexvalue1=indexvalue1*inputArray.get(i); 
           }
       }
       arrOutput1.add(indexvalue1);
      }
/*     
 for(Integer inta : arrOutput) {
            System.out.println(inta.get());
        }*/
        arrOutput1.forEach(System.out::println);
   
    }

}

Implement a function which, given an array of integers, returns a new array for which every index carries the vale of the product of the remaining elements.

SQL Server Lock Type and Mode

SQL Server Locks are used to restrict the user and access and prevent the unautorised access to data and at the same time.


SQL Server Lock Type and Mode



SQL Server have folowing Lock Type-

1- RID
2- Key
3- Page
4- Extent
5- Table
6- DB

SQL Server have folowing Mode Type-

1- Shared (S)
2- Update (U)
3- Exclusive (X)
4- Intent
5- Schema
6- Bulk Update (BU)

Saturday, August 17, 2019

SQL Server Profiler Logout class Interpretation

Features of Logout Class-

 ApplicationName  (Data Types- nvarchar) (Column Id- 10)
         Name of the client application(Software which runs on user end) that created the connection to an instance of SQL Server. This column is populated with the values passed by the application(Every application have a unique code) rather than the displayed name of  the program.
SQL Server Profiler Application  Name


 ClientProcessID  (Data Types- int) (Column Id- 9)
           ID assigned by the host computer(Servefr) to the process (User application)where the client application is running. This data column(Value) is populated if the client process ID is provided by the client

 CPU  (Data Types- int) (Column Id- 18)
          Amount of CPU time (in milliseconds) used by the user during their connection(End User)

DatabaseID  (Data Types- int) (Column Id- 3)
          ID of the database(A Special ID is assigned) specified by the USE database statement or the default database if no USE database statement has been issued for a given instance (Session). SQL Server Profiler displays the name of the database(Main Database of application) if the ServerName data column is captured in the trace and the server is available.                
Determine the value for a database by using the DB_ID function(Special function to identify).

DatabaseName  (Data Types- nvarchar) (Column Id- 35)
          Name of the database(Session database) in which the user statement is running.

Duration  (Data Types- bigint) (Column Id- 13)
         Amount of time since the user logged in() Time of session (approximately).

EndTime  (Data Types- datetime) (Column Id- 15)
         End time of the logout() When the session Close.

EventClass  (Data Types- int) (Column Id- 27)
        Type of event = 15 ( Their are 15 types of event like logging , logout, etc).

EventSequence (Data Types- int) (Column Id- 51)
        The sequence of a given event within the request (this will show the details of event.

HostName (Data Types- nvarchar) (Column Id- 8)
        Name of the computer on which the client is running (End User). This data column is populated if the host                  name is provided by the client( End User). To determine the host name, use the HOST_NAME function (Function to know the host name).

IsSystem (Data Types- int) (Column Id- 60)
        Indicates whether the event occurred on a system process or a user process1 = system, 0 = user (This method will let to know is this an automatic or manual enent).

LoginName (Data Types- nvarchar) (Column Id- 11)
        Name of the login of the user (either the SQL Server security login or the Microsoft Windows login            credentials in the form of DOMAIN \ username).

LoginSid (Data Types- image) (Column Id- 41)
         Security identification number (S I D) of the logged-in user. You can find this information in                           the sys.server_principals catalog view. Each S I D is unique for each login in the server.

NTDomainName (Data Types- nvarchar) (Column Id- 7)
         Windows domain to which the user belongs.

NTUserName (Data Types- nvarchar) (Column Id- 6)
         Windows user name

Reads (Data Types- int) (Column Id- 16)
         Number of logical read I/Os issued by the user during the connection.

RequestID  (Data Types- int) (Column Id- 49)
         ID of the request containing the statement.

ServerName (Data Types- int) (Column Id- 26)
         Name of the instance of SQL Server being traced.

SessionLoginName (Data Types- int) (Column Id- 64)
         Login name of that user who originated the session. For example, if you connect to SQL Server using           Login1 and execute a statement as Login2, SessionLoginName shows Login1                                             and LoginName shows Login2. This column displays both SQL Server and Windows logins.

SPID (Data Types- int) (Column Id- 12)
         ID of the session on which the event occurred( Session unique ID).


StartTime(Data Types- datetime) (Column Id- 14)
         Time at which the event started, if available.

Success (Data Types- int) (Column Id- 23)
         1 = success. 0 = failure. For example, a value of 1 indicates success of that permission  check and a                 value of 0 indicates failure of that check.

Writes (Data Types- bigint) (Column Id- 17)
         Number of logical write Inputs/Outputs issued by the user during the connection.

GroupID(Data Types- int) (Column Id- 66)
     ID of the work load group(Main session) where the SQL Trace event fires.

Translate