Monday, July 6, 2009

Running a simple Java Program in PDA

The PDA which im using is Motorola MC55.I was able to run a simple java program successfully after number of attempts.The things which i have done are

1.Check whether IBM J9 is installed or not.If not install.
2.Write java program in any IDE or notepad in your PC. (SamplePDA.java)

import java.awt.*;
public class SamplePDA {


public static void main (String [] args) {

Frame frame = new Frame ("Main Screen");
Label jl = new Label("My First PDA program..");

frame.add(jl);
frame.setSize(180,80);
frame.setVisible(true);

System.out.println("My First PDA Program..");
}

}

3.Compile the program with JDK1.4 or below.

4.Create a jar file with the class file.(SamplePDA.jar)

5.Create a shortcut file.(sample.lnk)

255#"\Program Files\J9\PPRO10\bin\j9.exe" "-jcl:ppro10" -cp \Sample\SamplePDA.jar SamplePDA


6.Sync the PDA and place the jar in particular location you want.I have placed the SamplePDA.jar in Sample folder.

7.Place the shortcut file(sample.lnk)on the start menu,so that we can execute
application from the start menu.

8.Click the shortcut file(sample.lnk) to run the application.

9.Now you will see a Frame displaying "My First PDA program".

When i tried to use Swing components it shown some error.!!!

Thursday, June 25, 2009

Connecting Java to MySql database

This is the first time im trying to connect MySql from Java.I knew very little about MySql.Previously i have used Oracle,MS Access and Sql Server.Following are the things i have done .

1. First i have created a database with a name 'sample'

mysql>create database sample;
mysql>use sample;

2.create a table 'first' with the following fields.

mysql>create table first(id int,name varchar(20));
enter some values, in my case
>insert into first values(1,'Lara');
>insert into first values(2,'Sachin');

Now your database/table is ready.
Im in 'root' user and my password is 'password'.
Before start writing Java code, first get the MySql Connector/J . I have downloaded it from MySql site .Click here
Unzip the folder mysql-connector-java-5.1.7 and check for the jar file mysql-connector-java-5.1.7-bin.jar.Now set this jar file in the classpath.

Setting ClassPath:
Go to Environment Variables in the System Properties.
Select CLASSPATH and click edit.(if there is no classpath variable create one)
in my case i already set one path so what i did was i added a ; and given my new path.

.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\mysql-connector-java-5.1.7\mysql-connector-java-5.1.7-bin.jar

classpath have been set and now we can write the java code.Below is the sample java code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;
public class SampleMysql
{
public static void main(String[] args)
{
Connection conn=null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn =DriverManager.getConnection("jdbc:mysql://localhost/sample?" +"user=root&password=password");
System.out.println("Connection established...");
Statement stmt = conn.createStatement();
ResultSet rs =stmt.executeQuery("Select id,data from first");
while(rs.next())
{
int id = rs.getInt(1);
String name = rs.getString(2);
System.out.println(" "+id+" "+name);
}
}
catch (Exception ex) {
System.out.println("SQLException: " + ex.getMessage()); }
}
}

After executing the output was:
1 Lara
2 Sachin

Tuesday, March 31, 2009

My Earth Hour

Day:28/march/2009


Even though i knew about Earth Hour before it was only when I saw a advertisement in which the number 60 is designed in globe,under it there was a site url www.earthhour.com i registered myself in that site.In Singapore they organized some events at Esplanade Park.There were some shops/booths like Starbucks,Old Chang Khee,Philips ,ACRES.We took picture in a booth,where they used recycle material for making cards.

The events started at 5 O'Clock but we reached there only around 6,that time there were around 100-200 people sitting around that area. As the sun went down the view of Esplanade,the bridge,UOB buildings was awesome.We walked around the bridge and took some pictures near the famous Merlion. At 8:15 we sat near the stage now the crowd grown around thousand,people started lighting candles.There was a countdown from 5 to 1 at 8:29:50   oops!! Most of the lights of those big buildings including the Esplanade went off.We were sitting in the dark.It was wonderful(!!) to see those buildings without light for an hour.This act has saved atleast some amount of energy.In TamilNadu as per Times Of India report 750MW of power was saved during Earth Hour.
Still we need to do a lot to Save our Planet. Do register in that site and show your support
Check out this video:Earth Hour2009

Monday, March 30, 2009

Installing WEME (IBM WebSphere Everyplace Micro Environment)

Installing IBM WebSohere Everyplace Micro Environment(WEME) on windows Mobile 6.1

1.Sync the PDA (in my case Motorolla MC55) to your PC using Active sync

2.Double click the exe file which you have downloaded from the IBM site

in my case its weme-wm2003-ppr010-5.7.2-p-20050304-1734xxx.exe

3.Select the language

4.Click next and accept the s/w license agreement,then click next.

Now the WEME is installed in your PC, the installer ask you to sync your PDA to install in it.

5.Click Continue
   In the PDA it will ask you where you want to install choose the location and click install. Thats it installation finished.

To check whether its installed correctly, go to Program files ,search for folder with the name J9.then inside j9 i.e J9/PPR010/examples select a file to check whether its working properly.

Friday, March 27, 2009

Formula1

When i was a child i never shown any interest in cars even today i dont have any interest in cars but im always thrilled to read and watch F1 races.Im a supporter of Ferrari (dont know why!) .This year's F1 season starts with this weekend Australian Grand prix on 29th march .Aftet all the drama of rule changes we can sit and enjoy racing.I like Massa to win the Drivers championship.... we will wait and see. Last year i had a chance to see the McLaren F1 car and Mika Hakkinen, i was thrilled to watch him drive the car on the Singapore road.

Ten teams going to fight it out,among them Vijay Mallaya owned Force India also.Hopefully this year they will have some points in the table.


No

Team

Driver 1

Driver 2

1.

Ferrari

Felipe Massa

Kimi Raikkonen

2.

McLaren

Lewis Hamilton

Heikki Kovalainen

3.

BMW Sauber

Robert Kubica

Nick Heidfeld

4.

Renault

Fernando Alonso

Nelson Picquet Jr

5.

Toyota

Jarno Trulli

Timo Glock

6.

Toro Rosso-Ferrari

Sebastien Bourdais

Sebastien Buemi

7.

Red Bull-Renault

Mark Webber

Sebastian Vettel

8.

Williams-Toyota

Nico Roseberg

Kazuki Nagajima

9.

Force India

Adrian Sutil

Giancarlo Fischella

10.

Brawn GP

Jenson Button

Rubens Barrichello


I personally prefers point system to determine the winner.Hopefully in future also they wont change this system.

click here for 2009 F1 calendar