Thursday, July 5, 2018

HashMap Stuff

package com;

public class Supplier {
int supp_number;   
String supp_name;

public Supplier(int supp_number, String supp_name) {   
    this.supp_number = supp_number;   
    this.supp_name = supp_name;   


}
-------------------------
package com;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
//import java.sql.SQLException;
import java.sql.Statement;
//import java.util.ArrayList;
import java.util.HashMap;
//import java.util.List;
import java.util.Map;

public class hashMapEx {
    public static void main(String[] argv) {

        System.out.println("-------- Oracle JDBC Connection Testing ------");

        try {

            Class.forName("oracle.jdbc.driver.OracleDriver");

        } catch (ClassNotFoundException e) {

            System.out.println("Where is your Oracle JDBC Driver?");
            e.printStackTrace();
            return;

        }

        System.out.println("Oracle JDBC Driver Registered!");

        Connection connection = null;

        try {
            connection = DriverManager.getConnection("jdbc:oracle:thin:@Lalama-Acer:1521:xe", "test_user", "test_user");

        } catch (SQLException e) {
            System.out.println("Connection Failed! Check output console");
            e.printStackTrace();
            return;

        }

        if (connection != null) {
            System.out.println("You made it, take control your database now!");
        } else {
            System.out.println("Failed to make connection!");
        }
       
        try {
String query = "select supp_number, supp_name from test_supplier";
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(query);
//ResultSetMetaData rsmd = rs.getMetaData();

/*
List columns = new ArrayList(rsmd.getColumnCount());
for(int i = 1; i <= rsmd.getColumnCount(); i++){
columns.add(rsmd.getColumnName(i));
}
*/

int seq = 1;
Map hmap=new HashMap(); 
while(rs.next()){
Supplier supp = new Supplier(Integer.parseInt(rs.getString("supp_number")), rs.getString("supp_name"));
hmap.put(seq, supp);
seq++;

}

//System.out.println(data);
rs.close();
stmt.close();
connection.close();

for(Map.Entry entry:hmap.entrySet()){    
int keycol=entry.getKey();
Supplier subObj=entry.getValue();
System.out.println(" Details: "+keycol+" Supplier Number: "+ subObj.supp_number+" Supplier Name: "+subObj.supp_name); 
}
       
        } catch (Exception e) {
            System.out.println("Issue in mapping to HashMap");
            e.printStackTrace();
            return;
       
        }
       
    }
}

Tuesday, October 1, 2013

The contrast

I was glancing at the road while going down in the lift, I saw a young lad (much younger than me), dressed in heavy smart casual, carrying a heavy partially worn out luggage bag, with two items in his hand.
He was a young sales man, working under scorching sun abiding to unfair obligation of the uniform, trying keep up the living.
Kept me thinking!
He must be holding a greater share of his family's income, making him a vital bread earner. Given the current market and employment conditions of sales force, his earnings would be on meager level.
Yet his commitment shown firm and rigid, he was glazing through the crowd towards the bus-stop or some place, where he could make a sale and meet his target and save his job and provide for his family.
May be his day get ends soon, but tomorrow will be whole another day, where the same agony, for him a life sustaining activity will be continued. it will not end there, for considerable time period of his life time, until he gives up and get promoted for a much forgiving position, this will continue.
Probably he will be responsible for his destiny, probably he did not give enough attention and thought to his work, education and life, even though other elements were provided to adequate level. Or probably, he did not receive any of this and he would probably glad of him self as he did not end up in streets.
Probably.
Yet, great inspiration for the observer, my self of course, might not be a positive one but would probably be a sigh of relief in comparison to his current life situation.
I think, probably not about most rewarding, exciting things, yet it keeps my brain busy, just giving the leverage to just to live a day!

Tuesday, August 20, 2013

Striking out the balance and then failing.

Past will probably haunt you in present. May be demanding the what is due all time to be paid. Do not know who keeps the tab on actual settlement!!!, yet for a struggling individual, like me this is huge.
One may or may not done things which attracts certain categorization in terms of good or bad. May be one has done mostly good stuff and very few bad, or may be other way round. it is imperative that, we as normal people are with certain expectations that those deeds tend to realize in favorable gains and rewards and cherish. Yet it is not.
You may not sell heroine, does not involve in flesh trade or cheat the innocent out for capital gains, yet you suffer to the maximum sometimes.
You may have pawned you jewelries so that immediate expenses of your loved ones are met, but it ended up been a burden to you with sort of suffering.
This is more of an example that, life is not fair and equal opportunity. Yet, it is not totally explainable on matter of how it actually works. We have phrases and ethics to promote good behavior by the book, but little convincing in part of actual practicality.
You see many, drug loads, cheaters and murders roam freely and indulge in greater luxury on sweat and blood of victims thus no repercussion what so ever.
Is it the manner society, world works ? is there a evolutionary explanation attached where the cultural and acceptable social norms fails to address ? not a clue my friends!
Now what is now ? do turn rogue like "Breaking Bad" ? will that solve everything for you ? whom to guess and suggest ?
Are we on a evolutionary change shift that human cultural and social aspects tend for an overhaul change ?
I'm battling my self to get some answers as life is a battle for me. Its hard and reluctant to give me some piece of mind, where i get to crash with people, dues and stigmas and prevail good.
I just want to see the end of the tunnel, but it seems not appearing or am I failing to see it ???

Thursday, July 18, 2013

In control of your self !!!!

What is the end of achievement in this material world. Of course, we could done our selves with the achievement of  Nirvana, yet we will be fortunate enough to attain that, it is wise enough to be good with the life we are spending as much extent possible.
People comes to your life, stay variable length of time and go as modes of demise and non-demise. Some we fall in love, some to fall in pray, some just get ignored. Actually our lives revolves and moves with the interactions and communications we keep with the people around. We don't keep relation with others, it is quite freaky, if so.
We define our lives based on the quality and degree of relationships we keep with others, thus making them decide who you are. This is the actual reason for intimidation we possess on all of our actions. Will this be approved ? Do I look ok ? etc etc. This mumble jumble, gives good as well as the bad. 
It is spineless to say, I'm been controlled, but fact to the matter is we are, for every single way, unless you are in control of your self for most possible extent.

Now what ? we keep getting intimidated, controlled and make us do good and bad both. Now what ? seriously.

We need to choose the correct people and be with them.
Choose what do you like in which way, then choose the people, that is the best way to be in control your self! seriously!!!