Sunday, January 8, 2012

Connecting a phpMyAdmin DB to Eclipse

This is a small tutorial on how to connecting a phpMyAdmin database to Eclipse.
Things you need - Eclipse , mySQLConnectorJXAMPP

Step 1
Once you install XAMPP, Open the install folder. There you will find 'xampp-control.exe' . Open it configure it to the following setting. Apache and Mysql are initiated by their start buttons.



Go to your browser, type 'localhost' to the address bar. Then click phpMyAdmin on the left side bar.

In the phpMyAdmin page, you are able to create the database of what you want and the tables necessary.

For more help -
InstallingConfiguringDevelopingWithXAMPP

Step 2
Open Eclipse. Create a project in where you want to connect to the database. Right click the project file > Build Path > Add External Archives

From the selection window, select the 'mysql-connector-java-5.1.18-bin.jar' file in the mySQLConnectorJ folder. (You may have a different version of the jar file)

Step 3
The code below is a class I made in connecting to a database in XAMPP.

//THE_CODE

package database;
import java.sql.Connection;
import java.sql.DriverManager;

public final class Connect {
private Connection conn;
public Connect(){
conn = null;
try{
String userName = "root";
String password = "";
String url = "jdbc:mysql://localhost/shop";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection(url, userName, password);
}
catch(Exception e){
System.out.println("Exception found");
}
}
public Connection getConnection(){
return conn;
}
public void closeConnection(){
try{
conn.close ();
}catch (Exception e) {
System.out.println ("Connection close error");
}
}
}


//DESCRIPTION
The code below is the main part in connecting to the database.


String userName = "root";
String password = "";
String url = "jdbc:mysql://localhost/shop";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection(url, userName, password);

The Strings userName and password are the username and password for the database.
"shop" mentioned there is the name of the database.
To execute SQL statements, follow the tutorial link given below -
http://www.kitebird.com/articles/jdbc.html

*Remember to close the connection after using it. The closeConnection function will execute it.

Hope all this is clear for you. :D

GO_HOME ?

As I was in the informatics Olympiad training pool sometime back. I used to be addicted in solving problems. This post is one such problem I solved on the 5th of May 2011 when I was bored. The problem is where a maze is given and a path needs to be found from a given source and a destination. The code was developed in 'Dev C++' .

//THE_CODE!!!!!

#include<iostream>
using namespace std;

const int mapWidth =10;
const int mapHeight=10;
char map[mapHeight][mapWidth]={' '};
int startY ;
int startX ;
int height, width;
int pathSteps=0;
int steps=0;
int tempSteps=0;
 
void displayMap(){
     for(int i=0;i<height;i++){
            for(int k=0;k<width;k++){
                    cout << map[i][k] ;
            }      
            cout << endl;
    }  
}

bool maze(int y, int x){
     if(y<0 || x<0 || y>height-1 || x>width-1){
            return false;    
     }  
     if(map[y][x]=='*' || map[y][x]=='d' ){
            return false;                            
     }
     if(y==startY && x==startX){
            return false;                
     }
     if(map[y][x]=='h'){
            cout << "FOUND! " << endl;
            return true;                            
     }
   
     map[y][x]='d';
     steps++;
   
     if(maze(y, x+1)){
            return true;        
     }
     if(maze(y+1, x)){
            return true;        
     }
     if(maze(y, x-1)){
            return true;        
     }
     if(maze(y-1, x)){
            return true;        
     }
     steps--;
     return false;
}


int main(){
    cin >> width;
    cin >> height;
    for(int i=0;i<height;i++){
            for(int k=0;k<width;k++){
                    cin >> map[i][k] ;
                    if(map[i][k]=='s'){
                              startY=i;
                              startX=k;                          
                    }
            }      
    }
    //displayMap();
    maze(startY, startX+1);
    tempSteps = steps;
    maze(startY+1, startX);
    if(steps<tempSteps){
            tempSteps = steps;                  
    }
    maze(startY-1, startX);
    if(steps<tempSteps){
            tempSteps = steps;                  
    }
    maze(startY, startX-1);
    if(steps<tempSteps){
            tempSteps = steps;                  
    }
    if(steps==0){
            cout << "NO PATH TO HOME!" <<  endl;          
    }else{
          cout << "Steps = " << steps << endl;
    }
    system("PAUSE");
    return 0;
}

//THE_INPUT
"
10
10
**********
*s****xx**
*x**xxx***
*xxxx*x***
*x****x***
*x****xx**
***hxxx***
**********
**********
**********
"

's' is the source;
'h' is destination;
'*' are blocks which cannot go through;
'x' are independent paths;

*Enter the above without quotes

//THE_OUTPUT


The output for the following maze, the number of steps needed to reach from 's' to 'd' is 14.

//DESCRIPTION
The solution is made using recursion. Rather than using 'for' loops, I thought it would be interesting to find the solution using recursion. The maze function solves the maze using each possible path. This algorithm does not find the shortest path.



FLASHY ENUF_?

As my life is almost being online on the internet, most of the time is spent on Facebook and Youtube. Recently I hit an interesting social entertainment known as a "Flash Mob". Flash mobs is where a group of people gather unexpectedly in public places performing an entertainment act.  I also checked Wikipedia, they say that is it an "pointless act". But I beg to differ. It is one of the most COOLEST things I've seen on my life. After watching videos of flash mobs in youtube so much, I hope to join a flash job later on ;) . I also noticed the it is kind of embarrassing at the start. But later on it gets better and better. Some of my favorite flash mob videos are linked here..




much love <3

Saturday, January 7, 2012

QR Code

Recently I noticed there are these weird looking square images used in banners, advertisements in the internet and as well as on the road. So I did some research on it and was able to find out what it is. Its called a QR Code.

qrcode

QR code stands for quick response code. This was used by the Toyota company to track vehicles in the manufacturing process in 1994.

I believe it seems to be a quick way to send messages using a security facility.
The internet has websites in encoding and decoding the QR Code.

Encoder - http://qrcode.kaywa.com/

Decoder - http://zxing.org/w/decode.jspx

This may be useful some day.... ;=)

Vertigo Cinema

I am currently in a team of people creating frag movies names "Vertigo Cinema". You may be wondering what frag movies are. They are actually a movie made up of game-plays of a games. These movies are created using different softwares such as Sony Vegas, Fraps, VDub, etc.

This is frag movie of a Call of Duty 4 player named robbye.


A frag movie by me... :)

WHOSE_TAIL?

I know the television can bring many weird and bad ideas. This is one of them. Cocktails!!!. Cocktails are alcoholic mixed drinks usually containing more than one ingredient. I still haven't consumed any cocktail in my life yet. But for now, I must say that there are some really interesting cocktails out there in the world. I will share 2 of my favorite cocktails for now.

The Grasshopper...


The grasshopper is a sweet, mint-flavored drink.
The recipe -


  • 3/4 oz green creme de menthe
  • 3/4 oz white creme de cacao
  • 3/4 oz light cream

Tequila Sunrise..
The Tequila Sunrise is considered a long drink with the sweetness of orange.
The recipe - 
  • 4 oz orange juice
  • 2 oz tequila
  • 1/2 oz grenadine
  • orange slice for garnish
  • maraschino cherry for garnish


Dont think anything bad of this :P  . But sometimes in life, you just gotta enjoy whats out there.

Career Statement

I am a self motivated, honest, dynamic, creative and hard working undergraduate who is able to use my own initiative in successfully completing tasks. I also possess a proven track record of positively contributing to work as part of a team.

I seek a challenging position within the IT industry where I could learn from and contribute to serving the organization to the fullest of my abilities. I want to use my creativity, verbal and written communication skills, team working skills, interpersonal skills and practical intelligence.

Software engineering (SE) is the application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software, and the study of these approaches. That is, the application of engineering to software. Software Engineering involves the development of software in a well defined and schematic manner. It is a field, which undergoes rapid changes along with time and technology, in which newer opportunities are raised to propose innovative and creative ideas.

I am a person who is keen in challenges. The tasks of a Software Engineer are such that they tend to become more challenging with time and progress of a given project.

The field of computer science undergoes many changes with time. So in order to meet with these changes, changes in the various fields of businesses, changes of requirements of end-users, the potential Software Engineer must be a person with capability of imagination.

And this is a virtue that I have always possessed. I love to think different, work things out differently and look for new aspects of developing software, so that the current requirements of the filed would be met with. The tasks of a Software Engineer involves to a greater degree, high inter-personal skills, communication skills both written and oral. 

I am still an undergraduate, and the accomplishment is further ahead. The knowledge that I gained while being an undergraduate has taught on how to  explored and learned in this field of software development.

Assets
Education and Credentials
· Satisfactory completed Training course JAVA APPLICATION DEVELOPMENT conducted by Computing Services Centre, University of Colombo School of Computing (2008)
· Completed Level 6 of International Certificate of Competence in Information Technology, International Curriculum and Assessment Agency (UK), endorsed by University of Southampton(2002).
· Participated at the 19th National Schools’ Software Competition (NSSC) 2008 conducted by Computer Society of Sri Lanka(CSSL)
· IOI (International Olympiad in Informatics) training.
· Currently enrolling the 2nd year of my B.Eng Software Engineering degree.

Additional Skills – Badminton, basic knowledge on music, cyber gaming.

My Career Ambition and Environment 
My career ambition is to get promoted to the position of a Software Architect position in 7 years of time. So by joining into the firm as a Software Engineer related to mobile applications, I would gain the required knowledge and experience that is required to be a Software Architect. And the regular promotion scheme at most main software engineering companies are very much in line with my career progression. Most of the work places in the field of software engineering in Sri Lanka have supportive, flexible corporate culture, which is beneficial to the prospective employees. They cherish equality and always welcome new ideas. Most of the leading software engineering companies have well balanced work schedule and acknowledges hard work whist also concentrating on interpersonal relationships between the firm as well as its clients, so that the benefits would be long term. They also provide its employees with cutting edge technology, which not only exposes them to the latest technology but also enhances their productivity as well as innovation.

Strengths
· Quick learner and critical analysis.
· High sense of professionalism.
· Ability to effectively plan and manage tasks given.
· Proactive and ability to think outside the box to deliver on goals.
· Ability to effectively track and monitor key milestones/ deliverables.
· Analytical and systematic approach to problem solving.