Labels

Tuesday, July 3, 2012

Steps for building a simple JDBC application?

1. Import Packages
2. Register JDBC Driver
3. Open a Connection
4. Execute a Query
5. Extract data from Result Set
6. Clean-Up Environment

A Simple Program to demonstrate the JDBC application working:

This is a simple program that retrieves  and displays the values of particular columns from the Employees table stored in the database.


//STEP 1. Import packages
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Date;
import java.sql.SQLException;

public class FirstQuery {
public static void main(String[] args) {
//Define Connection variable
Connection conn = null;
//Begin standard error handling
try{
//STEP 2: Register JDBC driver
String driver = "oracle.jdbc.driver.OracleDriver";  //for oracle database
Class.forName(driver);
//STEP 3: Open a connection
System.out.println("Connecting to database...");
String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:XE";
 /* this url will be different for the different databases */
String user = "username"; // username and password for the database authentication
String password = "password";
conn = DriverManager.getConnection(jdbcUrl,user,password);
//STEP 4: Execute a query
Statement stmt = conn.createStatement();
String sql;
sql = "SELECT SSN, Name, Salary, Hiredate FROM Employees";
ResultSet rs = stmt.executeQuery(sql);
//STEP 5: Extract data from result set
while(rs.next()){
//Retrieve by column name
int ssn= rs.getInt("ssn");
String name = rs.getString("name");
//Retrieve by column index as an example
double salary = rs.getDouble(3);
Date date = rs.getDate(4);
//Display values
System.out.print("SSN: " + ssn);
System.out.print(", Name: " + name);
System.out.print(", Salary: $" + salary);
System.out.println(", HireDate: " + date);
}
//STEP 6: Clean−up environment
rs.close();
stmt.close();
conn.close();
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
      if(conn!=null)
         conn.close();
    }catch(SQLException se){
            se.printStackTrace();
      }
}
System.out.println("Finished!");
}//end main
}

The Expected Output after you have created the databse with some values of these columns:

Connecting to database...
SSN: 111111111, Name: Harish, Salary: $5000.55, HireDate: 2010−09−16
SSN: 419876541, Name: Vikas, Salary: $1500.75, HireDate: 2011−03−05
SSN: 312654987, Name: Aman, Salary: $2000.95, HireDate: 2012−01−11
SSN: 123456789, Name: Sumit, Salary: $3080.05, HireDate: 2009−09−07
SSN: 987654321, Name: John, Salary: $4351.27, HireDate: 2011−12−31
Finished!
The values that you will store in the databse will be shown.

This was just a simple demonstration program to just give some idea about the JDBC connectivity.
In the later posts, the more detailed and programs for entering the data in the databse, updating and creating the database using either Statement or preparedStatement objects.

Common Programming and Development Tips for Java Developers?

Like any other Developers/Programmers Java Developers also need to take few common development tips into consideration while doing development activities. This article gives such 7 tips which can help Java developers in carrying out project in better way.
There are certain basic rules that must be followed for Java development. Ignoring them may result in the failure of your project. Some of these rules are:


1. Add comments to your code
All the software programmers know this fundamental rule of adding comment to their code, but most forget to implement it. There is no doubt that the comments do not practically contribute to the functionality of the program, but the problem arises that by the time you revisit the code that you wrote a few days earlier, you cannot remember its function. Sometimes the comments may have been added by other programmers which you may not be able to decipher. So, always remember to add comments to your code.

2. Do not complicate things
Do not try to develop complicated solutions for problems that can be resolved easily. Sometimes the programmers implement frameworks that are not needed at all. There are others who add property files, object-oriented solutions or threads to the applications that unnecessarily complicate the things. It is always advisable to consult an expert programmer if you are not sure of your steps.

3. Always avoid hard coding
Java developers often forget this rule or omit it for shortage of time. Hard coding may mess up the things. Always try to add one extra line of code that defines a static final variable.

4. Provide the requisite code
Unnecessary economy with code may prove harmful because writing fewer code lines may hamper the efficiency of the code. So write the full code required for the project.

5. Avoid inventing your own frameworks
Why invest your energy and time in inventing your own frameworks when thousands of them are available from open source. Most of these frameworks work fine as they have already been used in numerous other applications. Inventing your own framework may unnecessarily complicate the things.

6. Recognize the importance of Graphical User Interface—GUI
Most programmers tend to overlook the importance of the GUI. Try to make user-friendly rather than computer friendly designs. If you are not well versed with application interface, you should look for existing applications that have the similar interface requirements. Do not, therefore, try to reinvent the wheel.

Another important step is to first create the prototype. This is a very important step. The prospects wish to see what they are going to get. Moreover, you can also get their feedback or inputs before you develop your own application interface which may not be approved by the clients.

The best way to develop an application interface is to put yourself in the client’s shoes. Think about the application requirements from the user’s point of view. For example, you can create a summary screen with or without paging. You may be tempted to omit paging from the application because you think it to be quite a simple procedure, but it may not be so from the client’s perspective because the summary results can contain hundreds of rows of data.

7. Pay attention to preparing Document Requirements
You must document every business requirement no matter how hard pressed you are for time.

Monday, July 2, 2012

What are the BPM tools in market?

Savvion
PEGA
fujitstu
coryds
Fuego
Filenet
Appian

Loadrunner Interview Questions and answers?

1. Why should we automate the performance testing?

It’s a discipline that leverages products, people and processes to reduce the risk of application upgrade or patch deployment. It is about applying production work loads to pre-deployment systems while simultaneously measuring system performance and end-user experience.


2. What are all the things will be considered while doing performance testing?

Does the application respond quickly enough for the intended users?

Will the application handle the expected user load and beyond?

Will the application handle the number of transactions required by the business?

Is the application stable under expected and unexpected user loads?

Are we sure that users will have a positive experience on go-live day?

3. What are the LoadRunner components?

Virtual User Generator

Controller

Load Generators

Analysis

4. What is the LoadRunner testing process?

Plan load test

Create Vuser Scripts

Define Scenario

Run Scenario

Analyze results

5. What is remote command launcher?

The remote command launcher enables the controller to start applications on the host machine


6. How you develop the database vuser script?

Developing the database vuser script either by recording with load runner vuser script generator or by using load runner vuser script template.

7. How you load a load runner Agent?

While running the scenario loadrunner controller instructs the remote agent dispatcher to launch loadrunner agent. The controller instructs the loadrunner agent to initialize, run, pause and stop the vusers.

8. What is the difference between hits/second and requests/second?

Hits per second means the number of hits the server receives in one second from the vuser and the request per second is the no. of request the vuser will request from the server.

9. What are the reasons why parameterization is necessary when load testing the Web server and the database server?

Parameterization is useful for performance scripts for various reasons: -

1. We can use different data in scripts dynamically.

2. When URLs of AUT are parameterized, it becomes easy for the script to point to different application environments, i.e. Dev, QA or Prod depending upon the requirements.

3. Parameterizing helps in emulation real scenario as it avoids caching effect, if we send same data again and again while running scripts in iteration, then the data could be used from cache or from the temporary table from the database. Now if we send different data in each iteration the real performance transaction timers can be measured.

10. What are the advantages of using load runner?

Advantages are:-

1. With help of vusers reduces the human users

2. Reduces the requirement of the systems

3. Helps in the better usage of time and money

4. Effective utilization of automation

5. Everything done from a single point


11. What is the vuser in the scenario?

The vuser is virtual users nothing but those who simulate the real users. The virtual users who take the place of real users operating client software, such as IE sending requests using the HTTP protocol to IIS or Apache web servers

12. What is the difference between stop and gradually stop?

When you want to stop all the Vusers at once, this is called stop the Vusers at once. It is done in the scenario schedule section of the controller window. Suppose you want to stop the Vusers gradually, then you have to set the Vusers stop gradually. It is done in the scenario schedule section panel of controller window in loadrunner.



13. Explain the Load testing process?

Step 1: Planning the test. Here, we develop a clearly defined test plan to ensure the test scenarios we develop will accomplish load-testing objectives.

Step 2: Creating Vusers. Here, we create Vuser scripts that contain tasks performed by each Vuser, tasks performed by Vusers as a whole, and tasks measured as transactions.

Step 3: Creating the scenario. A scenario describes the events that occur during a testing session. It includes a list of machines, scripts, and Vusers that run during the scenario. We create scenarios using LoadRunner Controller. We can create manual scenarios as well as goal-oriented scenarios. In manual scenarios, we define the number of Vusers, the load generator machines, and percentage of Vusers to be assigned to each script. For web tests, we may create a goal-oriented scenario where we define the goal that our test has to achieve. LoadRunner automatically builds a scenario for us.

 Step 4: Running the scenario.

We emulate load on the server by instructing multiple Vusers to perform tasks simultaneously. Before the testing, we set the scenario configuration and scheduling. We can run the entire scenario, Vuser groups, or individual Vusers.

Step 5: Monitoring the scenario.

We monitor scenario execution using the LoadRunner online runtime, transaction, system resource, Web resource, Web server resource, Web application server resource, database server resource, network delay, streaming media resource, firewall server resource, ERP server resource, and Java performance monitors.

Step 6: Analyzing test results. During scenario execution, LoadRunner records the performance of the application under different loads. We use LoadRunner’s graphs and reports to analyze the application’s performance.

14. What Component of LoadRunner would you use to record a Script?

The Virtual User Generator (VuGen) component is used to record a script. It enables you to develop Vuser scripts for a variety of application types and communication protocols.

15. What Component of LoadRunner would you use to play Back the script in multi user mode?

The Controller component is used to playback the script in multi-user mode. This is done during a scenario run where a vuser script is executed by a number of vusers in a group.

16. What is a rendezvous point?

You insert rendezvous points into Vuser scripts to emulate heavy user load on the server. Rendezvous points instruct Vusers to wait during test execution for multiple Vusers to arrive at a certain point, in order that they may simultaneously perform a task. For example, to emulate peak load on the bank server, you can insert a rendezvous point instructing 100 Vusers to deposit cash into their accounts at the same time.

17.  What is a scenario?

A scenario defines the events that occur during each testing session. For example, a scenario defines and controls the number of users to emulate, the actions to be performed, and the machines on which the virtual users run their emulations.

18. How can a LoadRunner script be debugged?

Breakpoints and the Run Step-by-Step features of VuGen can be used for debugging and this information is written in the output window. There are debug settings in the Options area that allow the user to set the specifics about the trace that is performed during the execution of the scenario.

19. How does one write a user defined function in LoadRunner?

When creating a user-defined function, one must first create the external library that contains the function. This library must then be added to the bin directory of VuGen. Next, the user-defined function can be assigned as a parameter

20. Which function is used to capture dynamic data in the web Vuser script?

Web_reg_save_param is the function that saves dynamic data to a parameter.

21. What are the changes that can be made to run-time settings?

There are four run-time settings that can be made:

Pacing: This contains iteration count.

Log: This is where logging can be set to standard or disabled.

Think Time:  Capable of setting think time to be ignored or replayed.

General:  Allows the setting of Vusers for processes or multithreading.


22. How can web server related issues be found?

Web resource monitors can be used to find server related issues.  These monitors are capable of analyzing web server throughput, volume of hits per second during the execution of the scenario, the number of pages downloaded per second, and the volume of responses per second.

23. How can database related issues be found?

Monitors and the Data Resource Graph can be used to find database related issues. LoadRunner allow the tester to specify the resource that is to be measured before the controller is run.

24. What are the types of options are available for goal-oriented scenarios?

There are five goal options available:

Number of Vusers (concurrent)

Number of transactions/second

Number of hits/second

Number of pages/minute

Transaction response time






25. How many types of graphs are available in LoadRunner and what are they?

There are 5 types of graphs:

Network delay time graph – displays the time the elapses between request and response

Two transaction response time graphs – one for load and one for percentile

Hits/second graph – Shows application traffic volume.

Pages download/second graph – shows the rate that download processes are performed

26.. How can performance bottlenecks be identified?

LoadRunner has monitors that can be used to detect performance bottlenecks. These include network, web server, application server, and database server monitors. These monitors can be used to locate trouble spots in scenarios that cause increases response time and they track throughput, network delays, performance response time, hits/sec, etc.

27. How can one tell when correlation can be performed?

There are two ways to do this. One is to use the scan function to search for correlations and select a value from the resulting list. The second is to record a pair of scripts and then compare them to each other.

28. Where are automatic correlation options set?

The automatic correlation is set in recording options area on the correlation tab. From here, correlation can be enabled for the full script and rules for correlation can be defined.   Automatic correlation can be performed on a database by viewing the output window, scanning for correlation, and selecting the value that will be used.

29. Where is the number of iterations set for testing with Vuser scripts?

The number of iterations is set in the VuGen pacing tab in the Run-time settings area.

30. What is ramp up and how can it be set?

Ramp up is gradually increasing the load on a server.  This is simulated by gradually increasing the number of Vusers.  This feature can be found in the Scenario Scheduling Options.  When used, the initial value and the time to wait between periods are specified.

31. What is the benefit of running a Vuser script as a thread?

The advantage of running a Vuser script as a thread is that it allows more Vusers to be used for one load generator. Running Vuser scripts as processes utilizes a lot of memory because all of the loaded scripts use the same driver.  This limits the number of Vuser scripts that can be run on one generator.

32. How do you set LoadRunner to stop script execution when an error occurs?

Execution of Vuser scripts can be stopped on error using LoadRunner’s lr_abort function. The “Continue on error” option must not be checked in the Run-Time Setting menu.  It is helpful when it is necessary to abort execution when a certain error condition occurs. This function instructs the Vuser to stop performing what is in the Actions section, and to begin performing the vuser_end functions.  When execution is terminated, the Vuser status is changed to “Stopped”.

33. How are throughput and response time related?

The graph for throughput displays the quantity of data that the server sent to the Vusers in one second. When throughput is compared to the response time of transaction, it decreased as the response time decreased. In addition to this, the highest throughput and response times occur at approximately the same time.

34. Define think time and explain how you change the threshold for it.

Think time is the interval of time that a user must wait between actions. An example of this is the time that a user takes to review data after receiving it from the server before responding to it.  The threshold is the maximum level at which this time will be ignored.  The default threshold value is five seconds but this can be modified in the VuGen Recording options.


35. Explain the difference between standard and extended log?

The standard log contains a subset of functions and messages, which vary based on the type of Vuser, which are generated during the execution of a script. The extended log creates a more detailed listing of functions and messages.

Difference between Generation log and Replay log in Loadrunner?

Generation log & Replay log:

Generation Log:

Contains HTML source of recoded snapshots

Replay log: 

Contains HTML source of Replay snapshots (Make sure to enable extended log in the runtime settings.

VuGen Runtime settings ?

Think Time: Time delay between the user actions (Transactions)
Pacing: Time delay between the Iterations
Run Logic: number of iterations, This setting is applicable for both controller and Vugen.
Eg: Vugen: 1 user, 1 iteration, 2 or 3 Iteration
In Controller : Running hourly based Test,
  • Duration - 60 - Run logic iteration count will not be considered
  • Run until completion - Run logic iterations will be considered
  • Vugen : Vuser menu -> Run time settings - Run logic
  • Controller : Select the script(group) - Right click - Open Run time settings
  • Controller Run time settings will take priority over Vugen Run time settings

Log:   Vugen: Extended log enable to debug the scripts.
In Controller : Disable log while running big load test or select Send messages only error occurs
MiscellaneousAutomatic Transactions:
  • Define each Action as Transaction ( Default Action files: vuser_init, Action, Vuser_end) - Disable this option because we do not response time for action blocks, we are more intrested each user action/transaction response time
  • Define each step as a Transactions - Disable this also because it will provide each and every step(Get request or Post request) response time, rather than measuring response time each and every indivdual steps response time, it is recomednded to keep manual transaction points lr_start_transaction and lr_end_transaction


More information about run time settings:
Thread
1) If you run each Vuser as a thread, the Controller launches only one instance of the driver program (such as mdrv.exe), for every 50 Vusers (by default). This driver process/program launches several Vusers, each Vuser running as a thread. These threaded Vusers share segments of the memory of the parent driver process. This eliminates the need for multiple re-loading of the driver program/process saves much memory space, thereby enabling more Vusers to be run on a single load generator.
2) The main advantage of a multi thread environment is the ability to run more Vusers per load generator.
3) Only thread safe protocols should be run as threads.
Process
1) If you run each Vuser as a process, then the same driver program is launched (and loaded) into the memory again and again for every instance of the Vuser. Loading the same driver program into memory uses up large amounts of RAM (random access memory) and other system resources. This limits the numbers of Vusers that can be run on any load generator.
2) The protocols Sybase-Ctlib, Sybase-Dblib, Informix, Tuxedo, and PeopleSoft-Tuxedo are not thread safe, so need to run as process

How to parameterization in Loadrunner Vugen?

Loadrunner Vugen parameterization

·         It is the way of replacing a hard coded value in the script with a parameter which represents a list of values.
·    VuGen generates a script that contains the actual values used during recording and during script enhancement phase test engineer has to replace the recorded values with parameters is known as parameterizing the script.

Objectives of parameterization:
·         One  of the main objective of parametrization is to simulate real user behavior while running the test and we also use this to solve below problem
·          Solve Date constraints that may occur during playback
1.     Eg: When Second Virtual User accessing the Application  user may fail because of the 2/14/99 was yesterday!]
·          Solve data caching that may occur during playback
1.      Eg: When Second Virtual User accessing the Application, user will get data  from Cache 
·          Solve unique constraints that may occur during playback
Eg: Order number 1234 is already here
·          Solve data dependency that may occur during playback
·          Emulate real user activity
  • Exercise the server (Some times when we are searching with same keyword, the request will not go to database and it will get the data from the webserver cache and it will not exercise the server. Parameterization will solve this problem)
How to create Parameters:
·         Right click on the value and select “Replace with parameter” where we need to execute with different  set of values.
·         On the new window opened just give the Parameter name as user defined variable and Parmeter typeàselect any one from the drop down and Original Value will be default value and click on properties
·         After clicking on properties new window will be opened then click on Edit with notepad button and enter some list of values.
Note:  After entering values in notepad keep the cursor in new line and save the notepad and close it.

·         After entering the different set of values we have to customize the parameter properties to execute the script as user’s perspective.
Parameter Customization:
1.    Select Columnà By Number
                    à By Name
  These values are used when we have multiple columns in the same table with the same parameter type. We can select for each parameter by number as column number or by name as column name.
2.    File Formatà Column Delimiter
                à First Data Line
Column Delimiter drop down has values Comma,Tab,Space which are used to separate multiple columns.
First Data Line is a number which it uses that number row data at the time of execution. For eg: if you increase the number to 2 by using up button then the execution starts from 2nd row data.
3.    Select Next Row à Sequential
                        à Random
                        à Unique
Update Value on à Each Iteration
                        à  Each Occurrence
                        à  Once
If you select Select Next Row as Sequential and Update Value On as Each iteration then the users will execute the data sequentially for each iteration.
Click on close button and press CTRL+L buttons then parameter properties window will open with all parameters in left side and right side parameters data window.
If you click on Simulate Parameter button and then enter the iterations in check box and then click on simulate button then we will get the user behavior when the time of execution how the parameters will pass to the vusers.
If you select Update value on as Each Occurrence we can not simulate the parameter.
If you select Update value on as Once then the vuser will take only one set of data for all vusers. For ex: In the above snapshot we will get jojo and bean for each and every vuser we execute.
If you select Select Next Row as Random and Update value on as Each iteration then the user will pick random data for each and every iteration. At that we have to select for one parameter these values and select Same line as that parameter name for remaining parameters
For Ex: If we select RandomàEach iteration for Username then we have to select Same line as username for password.
If you select Select Next Row as Unique and Update value on as Each Iteration or Each Occurrence then automatically When Out of Values and Allocate Vuser values in the controller will be enabled.
When Out Of Valuesà Abort Vuser
                            à  Continue in a cyclic manner
                            à Continue with last value
Allocate Vuser values in the controller(Radio Buttons)
        Automatically allocate block size
        Allocate ______ values for each vuser
          
If you have values less than vusers at that time we have to select UniqueàEach IterationàAbort Vuser then what ever the users extra are aborted from the execution.
                                 OR
We can select UniqueàEach IterationàContinue in a cyclic manner
                                OR
We can select UniqueàEach IterationàContinue with last value
And we can select any of the two radio buttons for Allocate vuser values in the controller in the above three different cases
If you select Uniqueà Each Occurrence only
        Allocate ______ values for each vuser will be enabled for all the three cases
And you can click on Simulate Parameter button for each and every different options customized to view how the vuser behavior.
If you select Uniqueà Once all the vusers will execute with one set of data.
Once parameterization is done click on close button. Test the data execution procedure in the form of iterations in VUGen.