Archive

Archive for the ‘Algos’ Category

IBM – TGMC Eclipse, DB2 and Websphere

October 4, 2010 73 comments

Our team took nearly 3 weeks to start implementation, which is actually not required and I do not want other starters to waste so much time. So here is a PPT file which help starters. Work Guide for tgmc

UPDATE 1(15th Nov 2010) : Here is another pdf which might be helpful, check that too. Config_WASCE_Eclipse

UPDATE 2(19th feb 2011) : The slide number 104 in the ppt ( work guide for tgmc1 ) shows the selection of only one driver. Please make a correction that you need to select following two drivers instead of just one.
1. ‘com.ibm.db2/db2jcc/9.1/jar’
2. ‘com.ibm.db2/db2jcc_license_cu/9.1/jar’
The selection of the second driver type is missing in the ppt. You can select both the drivers simultaneously by pressing control button.

NOTE : The slide number 104 in the ppt shows the selection of driver version 8.1, but you can either choose driver version 8.1 or 9.1 . This depends on the DB2 version you are using.

I would suggest to read few articles on:

1. JDBC and types of JDBC drivers available.

2. Connection Pool

3. Recordset

This gives you a better idea and understanding when you are configuring.

I have also seen most of the team struggling for the JDBC test code. So below is the sample JDBC code which can be used for testing the JDBC :-

import java.sql.*;
public class connect {
public static void main(String[ ] args)
{
try
{
Class.forName( “com.ibm.db2.jcc.DB2Driver” );
Connection con = DriverManager.getConnection( “jdbc:db2://localhost:50000/testdb”, “db2admin”, “db2_pass” );
Statement statement = con.createStatement( );
ResultSet rs = statement.executeQuery(“select * from db2admin.db2_test_table”);
while ( rs.next( ) )
{
String firstname = rs.getString( “FIRSTNME” );
String lastname = rs.getString( “LASTNAME” );
System.out.println(“FirstName: “+firstname+”, Lastname: “+lastname);
}
statement.close( );
con.close( );
}
catch( Exception e )
{
e.printStackTrace( ); }
}
}
}

Following things to remember :-
1. In the above example in line no 8, the password has to be replaced with the one you choose. The password in the above example is “db2_pass“.

2. You need to change the table details also. The table schema used in above example is

db2_test_table(FIRSTNAME varchar(20), LASTNAME varchar(20)).

hope this helps.All the best. :)

NOTE : Both PPT and PDF tutorials found in this blog post are not designed by me and I too have got it from the web long ago. It is only for the purpose of sharing information with the world, so that, everyone can be benefited.

Implement Dijkstra’s Algorithm in C#

July 31, 2010 7 comments

This was a part of my project work done, when I was in semester 6. The project was “Routing System” was an online graphical solution, which displayed the shortest possible path between any two destinations. Well, I am not going to mention the various features which I had included in the system, rather I am giving an idea on implementation of dijkstra’s algorithm which was the central most attraction and requirement of the system.

Please refer and understand dijkstra’s algorithm before you implement it.

The implementation (source code) provided below can be used to find the smallest possible path from any node to any node:-

int startnode=-1,endnode=-1;
int count = 0;
int[,] A = new int[num_node, num_node];//main matrix
//num_node represents the number of nodes in the system.
//Assuming that the matrix A[num_node][num_node], which stores the distances between the pairs of node, is provided.
int[] C = new int[num_node];//to check if the node is visited or not.
int[] D = new int[num_node];//stores total distances between startnode and endnode through all the possible path.
string[] traverse = new string[num_node];//stores all the possible path between start node and end node.

//Dijkstra’s algorithm starts here————————————————————-
//startnode and endnode should be provided by user of the system through any input method in C#.

int minNode = startnode;
for (int i = 0; i < num_node; i++)
{
C[i] = i;
D[i] = A[minNode, i];
if (A[minNode, i] > 0)
{
traverse[i] = Convert.ToString(minNode) + “,” + Convert.ToString(i);//stores the path having direct connection
}
}

C[startnode] = -1;//marking the startnode as read by assigning it value -1

for (int k = 0; k < num_node; k++)//loop to find the next minimum node
{
int minValue = Int32.MaxValue;
for (int l = 0; l < num_node; l++)
{
if (C[l] >= 0)//check if the node is traversed before
{
if ((D[l] > 0) && (D[l] < minValue))
{
minValue = D[l];//stores the minimum value
minNode = l;//mimimum node is stored
}
}
}

C[minNode] = -1;//marking the minimum node as read by assigning its value -1
for (int m = 0; m < num_node; m++)
{
if (C[m] >= 0)//check if the node is traversed before
{
if (A[minNode, m] > 0)//checks if there is a direct connection
{
if (D[m] < 0)
{
D[m] = A[minNode, m] + minValue;
traverse[m] = traverse[minNode] + “,” + Convert.ToString(m);//stores the path
}
else if ((A[minNode, m] + minValue) < D[m])//checks if the distance is minimum
{
D[m] = A[minNode, m] + minValue;
traverse[m] = traverse[minNode] + “,” + Convert.ToString(m);//stores the path
}
}
}
}
}

D[endnode] ” and ” traverse[endnode] “ gives the smallest distance and path between start node and end node, which can be used as per the requirement

hope this helps many….. :)

Quick Reference to Linux Commands

August 14, 2009 1 comment

Many of us find it very difficult to remember the general linux commands(especially for a person with short term memory loss, like me ;-) ). Thus, everytime I Google for a particular command. I then thought of a page which will give a quick reference to the most common linux commands. Here it is–>

I will keep updating this page whenever i come across a command which is not included. I would request viewers to help me  increase the number…..

1. adduser :- This command will automatically add a new user to the system. The Bash script can be found in /usr/sbin if it needs to be changes.

2. alias :-

—–alias help=man – The alias command allows you to substitute a new name for a command.

—–alias long=ls -al – An alias can also contain command line options. Unless the alias definition is included in your

.login file it is only temporary.

3. apropos :- Display command names based on keyword search

4. at :-

—–at 1:23 lp /home/index.html – The at command runs a list of commands at a specified time (e.g. print @ 1:23).

—–at 1:50 echo “lp Job Done” – This uses the echo command to send a message at 1:50 saying a print job is done.

—–at -l – Lists all scheduled jobs; an alias for the atq command.

—–at -d 5555 – This will cancel job number 5555; an alias for the atrm command.

Read more…

interested in coding…….

Here is the link for all the people those who want to participate in coding contest.You can also solve coding question published by this site……

click on http://www.topcoder.com/

I will keep posting the question which i select and solve.check the category coding for questions……The programming language i use is C++………

Categories: Algos, Miscellaneous Tags:
Follow

Get every new post delivered to your Inbox.