Wednesday, November 17, 2010

e-Kalappai 3.0 Unveiled!

Finally, Mugunth and volunteers of thamizha.com came out with a successful Open source keyboard manager software e-Kalappai 3.0 (5.19MB). Currently e-Kalappai 3.0 supports Tamil language unicode text input with five keyboard layouts such as Tamil99, Phonetic, Typewriter, Bamini, Inscript in windows operating systems. It was written in C++ using Nokia's Qt Framework. e-Kalappai can be extended to any language as it is open source. Now e-Kalappai claims to be the first open source keyboard manager for Tamil language.

e-Kalappai is a popular freeware used by lot of Tamils around the globe for typing Tamil in computers. With the release of Ver 3.0, e-Kalappai became free software (GNU GPL License) too. This is a good news for the Tamil community. Kudos to Mugunth & Thamizha volunteers for taking this excellent initiative. I hope that the future versions of e-Kalappai will enable the input of other languages also.

Previous versions (1.0 and 2.0) of e-Kalappai were freeware (not free software) built using a third party proprietary Software called Tavulte Keyman(http://www.tavultesoft.com/). While trying to enhance e-Kalappai to the next level, Thamizha Team could not upgrade ekalappai 2.0b to new version since Tavultesoft didn't agreed for an OEM license for their latest Keyman software to create free eKalappai 3.0. So, Mugunth decided to rewrite the entire e-Kalappai from the scratch and release it under GNU GPL License as open source software.

He started working seriously on e-Kalappai 3.0 for windows platform from January 2010. In the mean time, some of his friends and ex-colleague Vijay Gupta joined hands with him for the development and testing of e-Kalappai 3.0 . Read mugunth's Blog post to know about his development experience.

Previously, beta versions of e-Kalappai 3.0 were released to the public for testing. After fixing all the reported bugs e-Kalappai 3.0 final was released by November 2010. Mugunth revamped his thamizha.com website and hosted e-Kalappai 3.0 binary installer files in that. Now you can download the latest version of e-Kalappai from thamizha website http://thamizha.com/project/ekalappai.

A post (written in Tamil with some screenshots) about e-Kalappai 3.0 and its features could be found at EzilNila website http://ezilnila.com/archives/1672

If you would like to take part in the development / testing of future versions of e-Kalappai, go through this link http://code.google.com/p/ekalappai/ . Source code of e-Kalappai 3.0 can also be downloaded from the above mentioned site.

Friday, October 29, 2010

A simple calculator using Adobe Flash Builder 4.0

Flex SDK is a free and open source product and can be downloaded from adobe's site
Flex is developer centric and so it does not have timelines, animation, movie clips, etc as in Flash. Flex uses MXML for defining the UI and actionscript for programming.
Using Flex we can build AIR(desktop) applications as well as Flash (web/RIA) applications.

Flex Builder is a commercial IDE for developing flex applications.
Later during the launch of its Flex v4.0, Adobe rechristened Flex Builder as Flash Builder.

Flash Builder 4 Standard is available for free (if you are a student or unemployed developer or faculty/staff of eligible educational institutions) from adobe website.

But we got Flash Builder 4 as free for the purchase of Adobe Master Collection Creative Suite 5. It is simple and easy to use. I’ve tried a simple calculator application (flash) in FB4.

The process of how i build a simple calculator using Flash Builder is explained below,

First Run the Flash Builder 4 software
In that click File > New Flex Project

A 'New Flex Project' Dialog box’ll pop up
In that mention the Project name as xCalc
Leaving other settings to default
Application type - Web
Flex SDK version - Use default SDK (currently "Flex 4.0")
Server technology - None/Other
and then click finish.

The xCalc.mxml file will be opened in the Source view.
Click the Design tab button to toggle to the Design view.
From the components window drag and drop a BorderContainer control into the Design Area.
Place a TextInput control inside that and add Button controls for numbers 0-9, operators +,-,*,/,=. Name the objects as per your wish and set the relevant Labels for them in the properties window.

Right click the button labeled ‘0’ and select 'Generate Click Handler', this will take u to the auto generated event handler function in the code view. Change the method name as per your wish in the fx:Script block as well as in the Button object tag. Remaining things in the code listed below are self explanatory.


<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" height="198" width="225">
<fx:Script>
<![CDATA[
import mx.core.*;
var str:String;
var operator:String;
var i:int=0;
protected function btn_0(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"0";
}
protected function btn_1(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"1";
}
protected function btn_2(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"2";
}
protected function btn_3(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"3";
}
protected function btn_4(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"4";
}
protected function btn_5(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"5";
}
protected function btn_6(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"6";
}
protected function btn_7(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"7";
}
protected function btn_8(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"8";
}
protected function btn_9(event:MouseEvent):void{
txtBx1.text=txtBx1.text+"9";
}
protected function btn_add(event:MouseEvent):void{
operator="add";
str=txtBx1.text;
txtBx1.text="";
}
protected function btn_sub(event:MouseEvent):void{
operator="sub";
str=txtBx1.text;
txtBx1.text="";
}
protected function btn_mul(event:MouseEvent):void{
operator="mul";
str=txtBx1.text;
txtBx1.text="";
}
protected function btn_div(event:MouseEvent):void{
operator="div";
str=txtBx1.text;
txtBx1.text="";
}
protected function btn_eq(event:MouseEvent):void{
i=parseInt(str);
switch(operator)
{
case "add":
{
i+=parseInt(txtBx1.text);
break;
}
case "sub":
{
i-=parseInt(txtBx1.text);
break;
}
case "mul":
{
i*=parseInt(txtBx1.text);
break;
}
case "div":
{
if(parseInt(txtBx1.text)!=0)
i/=parseInt(txtBx1.text);
else
i=0;
break;
}
}
txtBx1.text=i.toString();
str="";
operator="";
i=0;
}
protected function btn_clr(event:MouseEvent):void{
txtBx1.text="";
str="";
operator="";
i=0;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:BorderContainer x="6" y="6" width="213" height="136">
<s:TextInput x="4" y="3" width="202" height="23" id="txtBx1"/>
<s:Button x="110" y="31" label="=" id="btn10" click="{btn_eq(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="57" y="31" label="CE" id="btn15" click="{btn_clr(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="161" y="31" label="+" id="btn11" click="{btn_add(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="161" y="56" label="-" id="btn12" click="{btn_sub(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="161" y="82" label="*" id="btn13" click="{btn_mul(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="161" y="109" label="/" id="btn14" click="{btn_div(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="4" y="31" label="0" id="btn0" click="{btn_0(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="4" y="56" label="1" id="btn1" click="{btn_1(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="56" y="56" label="2" id="btn2" click="{btn_2(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="110" y="56" label="3" id="btn3" click="{btn_3(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="4" y="82" label="4" id="btn4" click="{btn_4(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="56" y="82" label="5" id="btn5" click="{btn_5(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="110" y="82" label="6" id="btn6" click="{btn_6(event)}" fontSize="12" width="45" height="20"/>
<s:Button x="4" label="7" id="btn7" click="{btn_7(event)}" fontSize="12" width="45" height="20" top="109"/>
<s:Button x="56" label="8" id="btn8" click="{btn_8(event)}" fontSize="12" width="45" height="20" top="109"/>
<s:Button x="110" label="9" id="btn9" click="{btn_9(event)}" fontSize="12" width="45" height="20" top="109"/>
</s:BorderContainer>
</s:Application>


Once the coding is finished, we can test the application by running the project.

We can run the project by Clicking Run > Run xCalc or by pressing Ctrl+F11.
It’ll pop up a browser window to display the application(swf file) which is embedded into the html page.

Monday, June 8, 2009

Connecting to a Database via JDBC Architecture

JDBC

• It is an API Specification developed by Sun MicroSystems

• It is a Core part of the standard Java Platform.

• It defines a uniform interface for accessing different relational databases .

• It is included in the standard JDK.

Accessing a Database [ Connecting to a Database via JDBC Architecture ]

1. Register the JDBC driver with the DriverManager

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

2. Establish a Database Connection using Database URL jdbc::

Connection con = DriverManager.getConnection("jdbc:odbc:dsname");

3. Execute an SQL Statement

i. Create a Statement object using Connection object's createStatement() method.

Statement stmt = con.createStatement();

ii. Query can be executed by using the Statement object's executeQuery()
method. It returns a ResultSet object that encapsulates the retrieved
data.

ResultSet rs = stmt.executeQuery("Query");

4. Process the Results

i. ResultSet object's next()& previous() methods can be used to
iterate through the rows of the result set.

ii. ResultSet object's getString() method is used to extract the value of
specified fields.


while(rs.next()){
System.out.println(rs.getString("fieldName"));
}

5. Close the Database Connection.

Database Connections should be closed after completing transactions.

rs.close();
stmt.close();
con.close();

[Written on: Monday, August 22, 2005 3:02:34 PM]

ADO.NET Database connections: SQLClient, OleDb, Odbc

ADO.NET
ADO.NET is a set of classes that expose data access services to the .NET programmer. ADO.NET provides a rich set of components for creating distributed, data-sharing applications. It is an integral part of the .NET Framework, providing access to relational data, XML, and application data. ADO.NET supports a variety of development needs, including the creation of front-end database clients and middle-tier business objects used by applications, tools, languages, or Internet browsers.

Code Samples of ADO.NET application that retrieves data from a database and returns it to the console.

SqlClient

using System;
using System.Data;
using System.Data.SqlClient;

class Sample
{
public static void Main()
{
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");

SqlCommand catCMD = nwindConn.CreateCommand();
catCMD.CommandText = "SELECT CategoryID, CategoryName FROM Categories";

nwindConn.Open();

SqlDataReader myReader = catCMD.ExecuteReader();

while (myReader.Read())
{
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
}

myReader.Close();
nwindConn.Close();
}
}

OleDb


using System;
using System.Data;
using System.Data.OleDb;

class Sample
{
public static void Main()
{
OleDbConnection nwindConn = new OleDbConnection("Provider=SQLOLEDB;Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");

OleDbCommand catCMD = nwindConn.CreateCommand();
catCMD.CommandText = "SELECT CategoryID, CategoryName FROM Categories";

nwindConn.Open();

OleDbDataReader myReader = catCMD.ExecuteReader();

while (myReader.Read())
{
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
}

myReader.Close();
nwindConn.Close();
}
}

Odbc

using System;
using System.Data;
using System.Data.Odbc;

class Sample
{
public static void Main()
{
OdbcConnection nwindConn = new OdbcConnection("Driver={SQL Server};Server=localhost;" +
"Trusted_Connection=yes;Database=northwind");

OdbcCommand catCMD = new OdbcCommand("SELECT CategoryID, CategoryName FROM Categories", nwindConn);

nwindConn.Open();

OdbcDataReader myReader = catCMD.ExecuteReader();

while (myReader.Read())
{
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
}

myReader.Close();
nwindConn.Close();
}
}

Installing Linux along with Windows - How?

Q.How to install a workable Linux environment along with existing Windows OS without losing the existing data on the hard disk?

For linux installation , a hard disk should be partitioned in to two or more partitions. First partition is the root (/) partition (indicated as /) and a swap partition. Other partitions are optional such as /usr , /home , /boot , etc. Because if you given only two partitions as root (/) and swap , the linux os will create the necessary directories such as /usr , /home , etc in the root (/) partition itself. The Swap partition should be twice of the system's RAM size. For example , if you are having 256 MB RAM then it should be allotted a 512MB size for the Swap partition.

For Installing Linux along with existing Windows OS , Consider the following situation, a hard disk with a capacity of 40GB  which is divided into 2 partitions as one primary 10GB and another extended partition 30GB. The Extended partition consists of three logical partitions each of size 10GB. see figure1.
 
First the last drive in the extended partition should be deleted. Take necessary backups before deleting that logical drive partition. Restart the machine and boot using the Linux installation CD. Partitioning is the major bottle neck in Linux Installation , other processes are simple , So select DiskDruid to manually partition the hard disk. Select the last drive indicated by hdax , where x is the big number (say hda7 ) ,i.e., it should be the free space allotted by deleting the last drive of your windows. Create the swap space by specifying its size. Create the root partition with size 6 to 8GB as per your requirements . Create other partitions if you have some space and if you feel they are necessary. A complete 3CD kit of Redhat Fedora requires 6GB hard disk space plus Swap space. See figure2.

I will always prefer Mandrake Linux to any one who is willing to shift to the rocksolid Linux platform from windows. Because , Mandrake Linux is the friendliest Linux Distribution. Its very simple, speedy and Lovable. Distributions Like RedHat are some what difficult to understand for a native windows user. Its User Interface is poor. It does not provide any good multimedia player. You have to type commands to use your cdrom and floppy disk. But in case of Mandrake Linux , It provides good Audio and Video software tools , Image editing softwares , Developer tools. It provides the supermounting facility; you can directly access the cds and floppies as like in windows. You can access your windows partitions without typing any commands.It provides a rich set of developer tools such as Qt , Python , Tcl/Tk , Java , C , C++ , PHP , Perl , MySQL , etc. Gimp – an excellent image editing software is available . Totempotent ,Mplayer – media players are available. Wine – a program that is used to run windows applications under Linux platform is provided. Mandrake provides an excellent User Interface which the native windows user doesn't find any difficulty to do his day-to-day jobs.

Note : This How to documentation is truly by my own experience. Any mishap or loss of data due to attempting to do linux installation as per this document is purely based on your own risk. If you have any doubts regarding this procedure ask me. If you success fully installed Linux then congrats. try to share your Linux experience with your friends.

My Linux experience started as an adventure. First of all i didn't know about partitions , I got a Mandrake Linux 8.2 CD from digit magazine. Its a single CD i.e., first CD only provided. So i tried by reading some instructions given in the magazine . My motherboard is intel 845GL for which mandrake 8.2 doesn't provide sound support and graphics support. Continuously the X-Windowing system crashed and only text mode is available for me .So I repeatedly installed linux after the Xserver crashes to get the GUI. Later i know about the vga ram setting of the BIOS and had made changes to get the stable system. Later i got the Mandrake Linux 10.1 Community Edition DVD. And my box is now powered with Mandrake Linux
[Written on: Wednesday, August 24, 2005 11:33:56 AM]