Latest Posts

Recent Posts

Wednesday, February 8, 2017

change the root password for MySQL in XAMPP

  1. Start the Apache Server and MySQL instances from the XAMPP control panel.
  2. After the server started, open any web browser and give http://localhost:8085/phpmyadmin/ (if you are running XAMPP on 8085 port). This will open the phpMyAdmin interface. Using this interface we can manager the MySQL server from the web browser.
  3. In the phpMyAdmin window, select SQL tab from the right panel. This will open the SQL tab where we can run the SQL queries.
  4. Now type the following query in the textarea and click Go
    UPDATE mysql.user SET Password=PASSWORD('rootPass') WHERE User='root'; FLUSH PRIVILEGES;
  5. Now you will see a message saying that the query has been executed successfully.
  6. If you refresh the page, you will be getting a error message. This is because the phpMyAdmin configuration file is not aware of our newly set root passoword. To do this we have to modify the phpMyAdmin config file.
  7. Open the file [XAMPP Installation Path] / phpmyadmin / in your favorite text editor.
  8. Search for the string $cfg\['Servers'\]\[$i\]['password'] = ''; and change it to like this, $cfg\['Servers'\]\[$i\]['password'] = 'rootPass'; Here the ‘password’ is what we set to the root user using the SQL query.
  9. Now all set to go. Save the file and restart the XAMPP server.

Monday, February 6, 2017

Designing Multi level, Multi Server, Multi Database System

I am providing consultancy in field of system design for quite some time . Recently one of my
acquaintance approach me to help him in designing a system for handling huge data gathering  and processing process.

I asked him what he meant by huge data gathering and processing. He explained me about the system He is looking forward to build a system to provide one stop solution for analyzing the data from various channels/sources. 

He has large customer base and all customer has multiple channels/sources to provide data. The size of data is varies in the rage of 3 to 5 million rows. Also the number of columns are not fix. 

As the number of columns were not fixed for unprocessed data, I asked him, "what about the number of column after processing the data". His answer was it is going to be fixed. 
on further discussion about data, We zeroed to MongoDB for storing unprocessed data and MySql for storing processed data. The primary reason behind using MongoDB for storing the unprocessed data  were
  1. The data size was huge
  2. The number of columns are not fixed i.e. schema of tables were not fixed.
  3. It is supported by strong developer community.
The processed data is structured so we decided to use MySql. MySql is also free database and well supported by developer community. 

After deciding the database we further discussed about the sources/channels of data. We zeroed that it is good strategy to bind the sources and scripts needed for gathering and processing of data. It will be further passed on to the client at the time of registration i.e. at the time of client registration the client will be mapped to sources/channels and it will automatically bind the scripts required for processing and gathering of data for the client. The advantage of using this strategy was
  1. The source/channel , script and client can work independently. If required the scripts can be added and deleted at client level.
  2. The logical change in source/channel script will not effect the current working of client
To make system more robust we save the details of client database on client level. It will help us at the time of gathering and processing process to save and manipulate the data.

Till now the structure was like

We discussed much about the data management, now we moved to data processing part. It is the point were a system can make or break. 
We started discussing about the advantages and dis-advantages of using a single server for executing scripts for gathering and processing data of all client.
  1. Risk of mixing client data
  2. If once process fails then all next process in queue will fail 
  3. As data amount is huge so it may be slow down the server
  4. client specific customization is difficult  
  1. Low cost
  2. easy to maintain
We come to conclusion that it is not good idea to use single server for gathering/processing of data for all client. 
We decide to use independent server for each client. The respective server of client will take care of data gathering and processing.   

On respective client server we will set the cron job. This Cron job executes a php script file which has the client Id value. With the help of client id , server gets the detail of scripts to be executed and the DB server detail. It also gets the other detail if required for the data channel/Source from the central MongoDB.
After getting the scripts it puts it into a designated folder with respective values. On the designated folder we will creat "INCRONTAB". As soon as the files are saved into folder the incrontab will come into action. It will start executing the files parlally.

The status of execution process are maintained for the respective client on central MongoDB server with various status FLAG like running, completed , error etc.

 The final architecture of system looks like as below image

The above solution will work well on combination of Linux/Unix server. To achieve same on windows server we need to use windows services. windows services provides the same working as we do with CRON. 
The only disadvantage of this architecture is that running cost for client is going to be HIGH.  

This architecture can be further optimized by using Job scheduler Queue. By Using Job scheduler the system can handle any exception occurred during data gathering or processing.


Monday, January 30, 2017


The FTP and HTTP is widely used protocol. I was surprised when i asked about the difference between both and 90% of people failed to answer it. Most of the people told me that FTP is file transfer protocol and HTTP is Hypertext transfer protocol.

To make people aware it, i thought i should write about it.

1.  All protocol are assigned specific port number. To communicate with the protocol we need to request on specific port of server so the first difference between FTP and HTTP is their protocol they work on. FTP works on 20, 21 port number and HTTP works on 80, 8080.

2.  The HTTP is used to transfer data from browser to server and vice-versa. FTP is used to transfer  data from one computer to another computer.

3. The most important difference is that  FTP is connection oriented and HTTP is connection less. Once FTP connection is established it will persist till the time it is not disconnected while in HTTP on every request a new connection is created , data is processed and  response is send back.

Feature FTP HTTP
TCP Port Number 20 and 21 80 and 8080
Function of protocol Used to transfer files from remote computer after connection is established. Used to transfer web pages from remote server after internet connection is established.
Connection It is connection oriented It is connection less
RFC reference documents RFC959, RFC765, RFC1738 RFC2616, RFC7230 and RFC7231

Friday, January 27, 2017

Abstract and virtual function and class in C#

i always find abstract and virtual as confusing. so i decided to do all test and write my experience of the same.I have consider all the angles, where a smart interviewer can trap you.
Most of the time the first question an interviewer ask is whats difference between abstract and virtual method in C#.

The simplest difference is that , body is needed for virtual function where it is declare, where as its just opposite in case of abstract function.

Lets examine this example

The first class is abstract class which contains a abstract method inabs()
if we give body to this method then it will give compile time error saying "cannot declare a body Function is marked as abstract".

Making a function abstract compels the inheriting class to define the abstract function.

    public abstract class abstractparent {     
        public abstract void inabs();      
        public void noabsparent()      
            Console.WriteLine("In Class Contaning abstract methode");      
    public class abstractchild : abstractparent {     
        public void noabschild()     
            Console.WriteLine("In Child class of Abstract Parent");     
        public override void inabs()     
            Console.WriteLine("In Child class functin definition of abstract");     

Also when we are declaring a abstract function in a class its necessary to use ABSTRACT keyword with class and function both.
A non abstract class can't contain the abstract method.if we defined a abstract method in non abstract class and try to compile it then it will give compile time error stating "A non abstract class has abstract function".you can check it by altering the above classes.

In virtual function we must have to specify the body of the virtual function.if we not specify the body then it will give compile time error stating "must declare a body because it is not marked as abstract, extern or partial".

#region virtual_function
    class virtual_parent
        public virtual void vir_parent()
            Console.WriteLine("IN vir_parent function of parent class which is defiend in parent class");
        public void non_vir_parent()
            Console.WriteLine("IN non_vir_parent function of parent class which is defiend in parent class");
    class virtual_child:virtual_parent
        new public void non_vir_parent()
            Console.WriteLine("IN non_vir_parent function of CHILD class which is defiend in CHILD class");
        public override void  vir_parent()
            Console.WriteLine("IN vir_parent function of CHILD class which is defiend in CHILD class");

Some tricky question interviewer may ask you.

1)Can we declare and defined a normal(not abstract, virtual,extern or partial) function in derived class which is already present in base class.
Yes we can do this in dotnet.
By using new keyword we can re-declare and redefine a normal function in drived class. for detail please refer the above code.

2)If above is true then how you will call the base class function by using child class object.

this we can do by explicitly type casting the base class object in to parent class

Use this code to see the result
virtual_child obj_virtual_child = new virtual_child();

I hope i have covered all the expect of the virtual and abstract.please let me know if any body have any query.
please also let me know if any body have problem in any concept of dotnet.
You can reach me at

Tuesday, July 7, 2015

Indexes on sql Server table

I have discussed with many interviewer and interviewee about the SQL Server tricky interview Questions. Most of them told me that Indexes and Triggers are most important area. Today we will discuss more about the Indexes and Triggers. To make it simple i will post question first and then explain the answer.

1. What is clustered and Non Clustered Index?

The leaf nodes of a clustered index contain the data pages i.e. in simple terms the clustered index stores the information how physically information is stored.It is same as the index page of a book.

A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. 
In simple terms we can say that the non clustered Index stores the logical ordering of data.
2. How many Cluster Index you can create on a table?

One Clustered Index is allowed per table

3. Can we create Clustered Index on Null value column? 
Yes we can create Clustered Index on a non-unique and nullable column. If the clustered index is not a unique index, SQL Server makes any duplicate keys unique by adding an internally generated value called a unique identifier.

4. How many Null value can a clustered Index column can take?

Only one NULL value is allowed in Clustered Index column as it is considered as a unique value.

5. Can we create Clustered Index on Non primary key column? 

 yes. We can create Clustered Index on Non primary key.

6. How many NON-Clustered Index you can create on a table?

SQL Server allows maximum up to 249 NON-CLUSTERED indexes that can be created in single table. This has been increased to 999 in SQL Server 2008 R2 version for both 32-bit and 64-bit server.

7. Can we drop Cluster Index on Primary Key. If yes then how it will work ?

Yes We can drop a Clustered Index on Primary key column and create it on another column.

8. Can we create a table without Clustered Index.

Yes we can.The table is called as Heap.Data is stored in the heap without specifying an order. To find a row we must now RID.  

9. Can we create Non-Clustered index on a table which donst have Clustered Index.

Yes we can create Non clustered index on a table which don't have clustered index

Tuesday, December 25, 2007

how to create colon of a existing table

we often require colon of table to take backup .Creating colon of table in different database requires different queries.these colons are used for temporary data manipulation. Some of the different queries used in different database are explain below.

CREATE TABLE new_table_name like existing_table_name
this will create new table with all the property of old table (like primary key , auto increment)

CREATE TABLE new_table_name select * from old_table
this query will create new table with all data and and structure but property like primary key are drooped
CREATE TABLE new_table_name (ID INT auto_increment primary key ) select * from old_table
this query will create new table with old table structure and with a new column " ID " .
if ID exist in old table then it will assign the property of primary key and auto increment to ID column;

This will create table newTable with the same columns as oldTable.
It will have no constraints or indexes. It will have zero(o) rows in it.
This will create table newTable with the same columns as oldTable and with all data of old table.

SQL 2000
SELECT * INTO emp_new from emp where 1=2
This will create the table structure alone.
SELECT * INTO emp_new from emp where 1=1
This will create the table structure with data.

Tuesday, December 4, 2007

Pass Multiple Arguments to Function

In our day to day programing life we find some situation when we need to pass multiple arguments at run time . we dont know the number of arguments to be passed by the user.

I find javaScript more handy. JavaScript provide a special property called " arguments " which contains the array of arguments passed to the function.
we can take this in an array and by length property of array we know the number of arguments passed.

function myFunc()
var arguments = myFunc.arguments;
for (var i = 0; i < arguments.length; i++) {
alert("Argument number " + i + " value = " + arguments[i]);

This function can be called with any number of arguments at the runtime like
vikFunc('neeraj', 'raju');
vikFunc('neeraj', 'raju','vinay','amole');


In c++ we use '...'(three dots) for passing multiple arguments.The first argument of the function represents the number of argument to be passed and the second argument '...'(three dots) represents the values to be passed.First argument is int and second argument could be any thing like int, double etc .....

we also need four things va_list which stores the arguments , va_start which initializes the list , va_arg which returns the arguments in the list and va_end which cleans up the
variable in the list. To get these we must include the “cstdarg ” header file.

va_list is like any other variable.

va_start is a macro which accepts two arguments, a va_list and the name of the variable that directly precedes the '...'(three dots ) . So, in the function a_function, to initialize a_list with va_start, you would write va_start ( a_list, x );

va_arg takes a va_list and a variable type, and returns the next argument in the list in the form of whatever variable type it is told. It then moves down the list to the next argument.

using namespace std;

double average ( int num, ... )
va_list arguments; // A place to store the list of arguments
double sum = 0;
va_start ( arguments , num ); // Initializing arguments to store all values after num
for ( int x = 0; x < num; x++ ) // Loop until all numbers are added
sum += va_arg ( arguments, double ); // Adds the next value in argument list to
sum. va_end ( arguments );
// Cleans up the list
return sum / num; // Returns some number
int main()
cout<< average ( 3, 12.2, 22.3, 4.5 );
cout<< average(5,3.3,2.3,3.5,6.7,2.9);