2009-09-21

Age of Mythology Vs Age of Empires

Age of Mythology is about mythical creatures, ancient Greek gods and heroes. Age of Empires is based on ancient real world wars and warriors. Altogether there are 32 stages in Age of Mythology default campaign. Age of empires campaigns has lot of stages divided in many parts. Age of Mythology campaign is flow as a one story and the game player get the feeling, that he/she is also a character of the game story. Age of Empires has three versions, Age of Empires I (The rise of Rome), Age of Empires II and Age of Empires III. Now there is Age of Empires 4 too. Age of Empires has historical real world characters such as Archimedes, Julius Caesar, Alexander and Vercingetorix. Age of Mythology has mythical creatures, heroes and known Greek gods such as Zeus, Poseidon, Osiris and Ra.

Age of Mythology has a beautiful story behind the game. Age of Empires also has games which are based on real world incidents.

Both games demonstrate different cultures in different nations and countries. The graphic designers of both games have given a much priority to cloths of the characters, Building structures and the environment. Both games are excellent strategic games which were designed by Microsoft. I think, both game developing teams were consist around 150 persons. After successfully completing the games the credits are shown. Both games give the feeling of being in the game to the user.

There are expansion packs for both games. Expansion pack for Age of Mythology is “Age of Mythology – The Titans”. Age of Mythology –Titans is consist with base games which were available in Age of Mythology and there are extra campaigns for Titans. We can also download many different campaigns and scenarios for the both games. Game users are free to design their own scenarios using scenario builder provided with the game. But there is no guarantee that the downloaded campaigns and scenarios will be interesting as the original scenarios.

To play Age of Mythology, high performance computer is needed relative to Age of Empires. Graphics is high quality and more advance in Age of Mythology. It demonstrate God powers and other mythical features in an excellent manner.

There is no Age of Mythology II. The Age of Mythology Titans Expansion is considering as the 2nd version of Age of Mythology. But it is actually continued from the where Age of Mythology finished. In Age of Mythology Titans expansion, the Titans campaigns are starting from the where Age of Mythology ends. But the main role in Age of Mythology, Hero Arkantos, is not there. He is dead and the main role in Age of Mythology Titans expansion is his son. In Titans expansion, Arkantos is acting as a god but can’t use in the game. Al together there are 12 stages in Titans expansion campaigns. In last few stages, there are different Titans and we have to deal with them using different strategies. In the last stage (12th stage) only we can have a Titan in our own. Following video shows how our titan (Gaia) fight with the enemy titan (Kronos) and end the Age of Mythology Titans expansion.

Kronos is the son of Gaia and he is the king of all Titans. It’s said that Greek gods are children of Titans. But the power of Olympians is the fact that keep the Titans imprisoned.

It’s actually very nice game flowing like a movie.

When talking about Age of Mythology and Age of Empires, we can’t forget about the sounds and music. There are high quality sounds provided in both games. Music composers have done a great job in here.

In Age of Mythology there are three kinds of gods to follow. Those are Greek, Egyptian and Norse. In the titans expansion, we can worship to Titans and at the end we can build a Titan gate and release a Titan. In Age of Empires, there are different different Ages to advance through. Like wise in Age of Mythology, we have to worship gods/titans to advance through. According to the God or Titan we choose to worship, the powers and technology will be having. There are 9 major gods including, Zeus, Hades, Thor, Loki, Ra, Set. Age of Mythology is a game based on the way the humans were used in the war between Underworld and Olympus.

 

In the Titans Expansion, it’s really hard to play, if we set the difficulty mode to Titan. The computer will advanced very quickly by gathering resources immediately. Then it will release the Titan in a short period of time and Titan will come to our base to attack. So the game will be over after the computer release the Titan. Titan is accompanied by a huge army. So, there is no way to attack them back without using cheats.

2009-09-16

What is the best Chat?

Nowadays, Chat is a very popular medium of communicating. These days it’s becoming very popular among professionals to communicate even officially. Some IT companies are conducting their interviews through video and voice chat.

When it comes to smileys, the yahoo messenger provides the best Emoticons. Here is the descending order of quality of smileys

Yahoo messenger > Google Talk, Skype > Facebook

Among the Chats mentioned above, facebook chat is the worst. Google Talk has very simple and user friendly GUI and Google talk is very reliable. Facebook chat is not reliable and poor with smileys. Yahoo messenger 10 is enriched with high quality animating smileys.

In Skype, if you have contacts from different countries other than your country, you can view their times.

2009-09-15

How to shift a given context in an iPhone application

CGContextTranslateCTM(context, 50, -350);

Code to shift the given context is shown above. First parameter is the context which wanted to shift. Second parameter is the value you want to shift the context along the x-axis and third parameter is the value you want to shift the context along the y-axis.

How to rotate a Context in an iPhone application

CGContextRotateCTM(context, radians(90));

Code to rotate a context is shown above. Give the context as the 1st parameter and give the degrees to the radians method. radians method is shown below.

static inline double radians (double degrees) {return degrees * M_PI/180;}

(Note: you may need to import math.h to use M_PI constant)

Add a timer in an iPhone application

Here is the code to add a timer object to an iPhone application

NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(startTimer) userInfo:NULL repeats:YES];   

scheduledTimerWithTimeInterval – This is the time interval for timer to call a method

selector – This is the method which runs after the interval

repeats – If the user wants continuously run the particular method after the interval, this must be assigned as YES. Otherwise this will be NO.

How to view .mkv files in low performance computers

Open the VLC media player. Then click Tools –> Preferences. Then select Input & Codecs. Set the default caching level to Higher latency and Post-Processing quality to 999999999. Finally save the changes. Optionally you can also set the power setting on the computer to high performance for best results. Now you can view the .mkv files without chopping.

Create a Chat server in Java RPC

Create the .x file as follows and save it as msg.x


struct overdata{
int a;
String b;
};
program Chat {
version Chat_V1 {
String get(int)=2;
String get1(void)=4;
void chat(overdata)=3;
} = 1;
} = 1234567;


Create the client code as follows and save it as NewJFrame.java


import netbula.ORPC.*;
public class NewJFrame extends javax.swing.JFrame {
public NewJFrame() {
initComponents();
strart();
strart1();
}
@SuppressWarnings("unchecked")
//
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jButton3 = new javax.swing.JButton();
jToggleButton1 = new javax.swing.JToggleButton();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Chat System");
setAlwaysOnTop(true);
setBackground(new java.awt.Color(0, 0, 0));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jButton1.setText("Send");
jButton1.setToolTipText("Send Message");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Client Number");
jButton2.setText("Receive");
jButton2.setToolTipText("Receive Messages");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jLabel3.setText("Client Number");
jButton3.setForeground(new java.awt.Color(255, 0, 0));
jButton3.setText("Exit");
jButton3.setToolTipText("Exit the Chat System");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jToggleButton1.setForeground(new java.awt.Color(0, 0, 255));
jToggleButton1.setText("Enable polling");
jToggleButton1.setToolTipText("Push for enable");
jToggleButton1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(), javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)));
jToggleButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleButton1ActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel4.setForeground(new java.awt.Color(51, 51, 51));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(65, 65, 65)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(79, 79, 79))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
.addComponent(jToggleButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(70, 70, 70)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(72, 72, 72))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(194, 194, 194))))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jToggleButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
pack();
}//
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
Chat_cln cl = new Chat_cln("localhost", "udp");
Integer i=Integer.parseInt(jTextField1.getText());
String message=jTextArea1.getText();
overdata od=new overdata();
od.a=i;
od.b=message;
cl.chat(od);
System.out.println("Sent message");
}catch (rpc_err e) {
System.out.println("rpc: " + e.getMessage());
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
Chat_cln cl = new Chat_cln("localhost", "udp");
Integer i=Integer.parseInt(jTextField2.getText());
System.out.println(" Got message ");
String all=cl.get(i);
jLabel2.setText(all);
}catch (rpc_err e) {
System.out.println("rpc: " + e.getMessage());
}
}
//polling mechanism
private class Poll extends Thread{
public void run(){
while(true){
//get the remote object from the registry
try {
Chat_cln cl = new Chat_cln("localhost", "udp");
String all=cl.get1();
jLabel2.setText(all);
}catch (rpc_err e) {
System.out.println("rpc: " + e.getMessage());
}
}
}
}
Poll p=new Poll();
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(jToggleButton1.isSelected()){
p=new Poll();
jLabel4.setText("Polling enables");
p.start();
}
else{
jLabel4.setText("Polling disabled");
p.stop();
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
private class Animate extends Thread{
public void run(){
String str=new String();
str="Exit";
for(;;){
for(int i=0; i<=str.length();i++){ jButton3.setText(str.substring(0, i)); try { Animate.sleep(200); } catch (InterruptedException ex) { } if(i==str.length()){ try { Animate.sleep(2000); } catch (InterruptedException ex) { } } } } } } private class Animate1 extends Thread{ public void run(){ String str=new String(); str="CHAT SYSTEM - CREATED BY RUCHIRA CHANAKA"; for(;;){ for(int i=0; i<=str.length();i++){ setTitle(str.substring(0, i)); try { Animate1.sleep(200); } catch (InterruptedException ex) { } if(i==str.length()){ try { Animate1.sleep(2000); } catch (InterruptedException ex) { } } } } } } private void strart1(){ Animate1 a=new Animate1(); a.start(); } private void strart(){ Animate a=new Animate(); a.start(); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; private javax.swing.JToggleButton jToggleButton1; // End of variables declaration }
Create the Server code as follows and save it as Chat_server.java
import netbula.ORPC.*;
import java.util.*;
class Chat_server extends Chat_svcb {
//implement the server function,
//let's just echo the msg back
static HashMap messages=new HashMap();
//chat code
public void chat(overdata od){
Integer a=od.a;
String msg=od.b;
boolean flag = false;
if(!messages.isEmpty()){
Integer numbers[] = new Integer[messages.size()];
messages.keySet().toArray(numbers);
for(int i=0;i al=new ArrayList();
al.add(msg);
messages.put(a, al);
}
}
//get code
public String get(int a){
Integer numbers[] = new Integer[messages.size()];
messages.keySet().toArray(numbers);
boolean flag = false;
for(int i=0;i" all="">
flag=true;
while(b.hasNext()){
all_messages=(String) b.next();
all+=(all_messages+"
");
}
return ""+all;
}
}
if(!flag){
return "There are no messages from Client "+a;
}
return "test";
}
//method used for polling
public String get1(){
Set s=messages.keySet();
Iterator use=s.iterator();
String all="";
while(use.hasNext()){
ArrayList temp;
int temp_no=(Integer)use.next();
temp=messages.get((Integer)temp_no);
String all_messages="";
if(temp!=null){
Iterator b=temp.iterator();
String final_messages="Message to Client "+temp_no+": ";
while(b.hasNext()){
all_messages=final_messages+(String) b.next();
all+=(all_messages+"
");
}
}
}
return all;
}
//main function runs the server
public static void main(String srgv[]) {
//let's run the server using the run() method in Svc
//For more flexibility, one could use the TCPServer and UDPServer directly
try {
new Chat_server().run();
} catch (Exception e) {
System.out.println("a major problem");
}
}
}</NUMBERS.LENGTH;I++){></NUMBERS.LENGTH;I++){></INTEGER,></INTEGER,>

  • Open the Command Prompt
  • Change directory to the current working directory (RPC)
  • Compile the msg.x file
    • “jrpcgen msg.x”

  • Compile the client code ·
    • “javac –cp .;lib/orpc.jar NewJFrame.java”
  • Compile the server code ·
    • “javac –cp .;lib/orpc.jar Chat_server.java”
  • Compile the port mapper code ·
    • “javac –cp .;lib/orpc.jar pmapsvc.java”
  • Run the port mapper ·
    • “java –cp .;lib/orpc.jar pmapsvc”

clip_image002[13]

  • Run the server
    • “java –cp .;lib/orpc.jar Chat_server”

clip_image002[15]

  • Run the client
    • “java –cp .;lib/orpc.jar NewJFrame”

image

image

Create a Chat server in Java RMI

Create the Interface class as follows and name it as Inter.java

import java.rmi.*;

public interface Inter extends Remote
{
  public void chat(Integer a,String b) throws RemoteException;
  public String get(Integer a) throws RemoteException;
  public String get() throws RemoteException;
}

Create the Server class as follows and name it as Chat_server.java

import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.util.*;

public class Chat_server extends UnicastRemoteObject implements Inter{

    static HashMap<Integer, ArrayList> messages=new HashMap<Integer, ArrayList>();

    Chat_server() throws RemoteException{
        super();
    }

    public void chat(Integer a, String msg) throws RemoteException{

        boolean flag = false;

    if(!messages.isEmpty()){
    Integer numbers[] = new Integer[messages.size()];
    messages.keySet().toArray(numbers);

    for(int i=0;i<numbers.length;i++){

        if(a.intValue()==numbers[i].intValue()){
        ArrayList temp;
        temp=messages.get(a);
        temp.add(msg);
        messages.put(a, temp);
        flag=true;
        }

    }

    }

    if(!flag){
            ArrayList<String> al=new ArrayList<String>();
            al.add(msg);
            messages.put(a, al);
    }

    }

    public String get(Integer a) throws RemoteException{

        Integer numbers[] = new Integer[messages.size()];
        messages.keySet().toArray(numbers);
        boolean flag = false;

    for(int i=0;i<numbers.length;i++){

        if(a.intValue()==numbers[i].intValue()){
        ArrayList temp;
            temp=messages.get(a);
            Iterator b=temp.iterator();
            String all_messages="<html>", all="";
            flag=true;

            while(b.hasNext()){
                all_messages=(String) b.next();
                all+=(all_messages+"<br>");
            }

            return "<html>"+all;

        }

    }

        if(!flag){
            return "There are no messages from Client "+a;
        }

        return "test";

    }
   
    //method used for polling
   
    public String get() throws RemoteException{

        Set s=messages.keySet();
        Iterator use=s.iterator();
        String all="";

    while(use.hasNext()){

        ArrayList temp;
        int temp_no=(Integer)use.next();
            temp=messages.get((Integer)temp_no);
            String all_messages="";

            if(temp!=null){
            Iterator b=temp.iterator();
            String final_messages="<html><I><tt>Message to Client "+temp_no+": </tt></I>";

            while(b.hasNext()){
                all_messages=final_messages+(String) b.next();
                all+=(all_messages+"<br>");
            }

            }
           
    }

    return all;

    }

    public static void main(String args[]){

        try{
        System.setSecurityManager(new RMISecurityManager());
        //set the security manager

        //create a local instance of the object
        Chat_server server = new Chat_server();

        //put the local instance in the registry
        Naming.rebind("CHAT-SERVER" , server);

        System.out.println("Server waiting.....");
        }

        catch (java.net.MalformedURLException me){
        System.out.println("Malformed URL: " + me.toString());
        }

        catch (RemoteException re){
        System.out.println("Remote exception: " + re.toString());
        }

    }

}

Create the Client class as follows and name it as NewJFrame.java

import java.rmi.*;
import java.rmi.server.*;

public class NewJFrame extends javax.swing.JFrame {

    public NewJFrame() {
        initComponents();
        strart();
        strart1();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jToggleButton1 = new javax.swing.JToggleButton();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Chat System");
        setAlwaysOnTop(true);
        setBackground(new java.awt.Color(0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        jButton1.setText("Send");
        jButton1.setToolTipText("Send Message");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Client Number");

        jButton2.setText("Receive");
        jButton2.setToolTipText("Receive Messages");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel3.setText("Client Number");

        jButton3.setForeground(new java.awt.Color(255, 0, 0));
        jButton3.setText("Exit");
        jButton3.setToolTipText("Exit the Chat System");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jToggleButton1.setForeground(new java.awt.Color(0, 0, 255));
        jToggleButton1.setText("Enable polling");
        jToggleButton1.setToolTipText("Push for enable");
        jToggleButton1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(), javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)));
        jToggleButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButton1ActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(51, 51, 51));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(65, 65, 65)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(79, 79, 79))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                            .addComponent(jToggleButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(70, 70, 70)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(72, 72, 72))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(194, 194, 194))))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jToggleButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
       
            // set the security manager for the client
            System.setSecurityManager(new RMISecurityManager());
     
            //get the remote object from the registry
            try{
            System.out.println("Security Manager loaded");
            String url = "//localhost/CHAT-SERVER";
            Inter remoteObject = (Inter)Naming.lookup(url);
            System.out.println("Got remote object");
            Integer i=Integer.parseInt(jTextField1.getText());
            String message=jTextArea1.getText();
            remoteObject.chat(i, message);
            System.out.println(" Sent message ");
            }
           
            catch (RemoteException exc){
            System.out.println("Error in lookup: " + exc.toString());
            }
       
            catch (java.net.MalformedURLException exc){
            System.out.println("Malformed URL: " + exc.toString());  
            }
       
            catch (java.rmi.NotBoundException exc){
            System.out.println("NotBound: " + exc.toString());
            }
       
    }
   
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
       
            // set the security manager for the client
            System.setSecurityManager(new RMISecurityManager());
     
            //get the remote object from the registry
            try{
            System.out.println("Security Manager loaded");
            String url = "//localhost/CHAT-SERVER";
            Inter remoteObject = (Inter)Naming.lookup(url);
            System.out.println("Got remote object");
            Integer i=Integer.parseInt(jTextField2.getText());
            System.out.println(" Got message ");
            String all=remoteObject.get(i);
            jLabel2.setText(all);
            }
           
            catch (RemoteException exc){
            System.out.println("Error in lookup: " + exc.toString());
            }
       
            catch (java.net.MalformedURLException exc){
            System.out.println("Malformed URL: " + exc.toString());  
            }
       
            catch (java.rmi.NotBoundException exc){
            System.out.println("NotBound: " + exc.toString());
            }
    }
   
    //polling mechanism
   
    private class Poll extends Thread{
   
        public void run(){
       
        while(true){
            // set the security manager for the client
            System.setSecurityManager(new RMISecurityManager());
     
            //get the remote object from the registry
            try{
            System.out.println("Security Manager loaded");
            String url = "//localhost/CHAT-SERVER";
            Inter remoteObject = (Inter)Naming.lookup(url);
            System.out.println(" Got message ");
            String all=remoteObject.get();
            jLabel2.setText(all);
            Poll.sleep(10000);
            }
           
            catch (RemoteException exc){
            System.out.println("Error in lookup: " + exc.toString());
            }
       
            catch (java.net.MalformedURLException exc){
            System.out.println("Malformed URL: " + exc.toString());  
            }
       
            catch (java.rmi.NotBoundException exc){
            System.out.println("NotBound: " + exc.toString());
            }
           
            catch (InterruptedException ex) {
            }
           
        }
       
        }
   
    }
   
    Poll p=new Poll();
   
    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        if(jToggleButton1.isSelected()){
            p=new Poll();
            jLabel4.setText("Polling enables");
            p.start();
        }
        else{
            jLabel4.setText("Polling disabled");
                p.stop();
        }
    }
   
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        System.exit(0);
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }
   
    private class Animate extends Thread{

        public void run(){
            String str=new String();
            str="Exit";

            for(;;){
                    for(int i=0; i<=str.length();i++){
                     jButton3.setText(str.substring(0, i));
                try {
                    Animate.sleep(200);
                } catch (InterruptedException ex) {
                }
                if(i==str.length()){
                try {
                    Animate.sleep(2000);
                } catch (InterruptedException ex) {
                }
                }
                    }
            }

        }

    }
   
        private class Animate1 extends Thread{

        public void run(){
            String str=new String();
            str="CHAT SYSTEM - CREATED BY RUCHIRA CHANAKA";

            for(;;){
                    for(int i=0; i<=str.length();i++){
                     setTitle(str.substring(0, i));
                try {
                    Animate1.sleep(200);
                } catch (InterruptedException ex) {
                }
                if(i==str.length()){
                try {
                    Animate1.sleep(2000);
                } catch (InterruptedException ex) {
                }
                }
                    }
            }

        }

    }
   
    private void strart1(){
    Animate1 a=new Animate1();
    a.start();
    }

    private void strart(){
    Animate a=new Animate();
    a.start();
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JToggleButton jToggleButton1;
    // End of variables declaration

}

Open the Command Prompt

  • Change directory to the current working directory (RMI)
  • Compile the interface class
    • “javac Inter.java”
  • Compile the Server class
    • “javac Chat_server.java”
  • Generate the stub
    • “rmic Chat_server”
  • Compile the Client class
    • “javac NewJFrame.java”
  • Start the RMI registry
    • “start rmiregistry”
  • Start the server
    • “java -Djava.security.policy=policy.all Chat_server” 
    clip_image002

  • Start the Client
    • “java -Djava.security.policy=policy.all NewJFrame”


image image 


    2009-09-14

    How to create a splash screen in J2ME

    import java.io.IOException;
    import javax.microedition.lcdui.*;

    public class MIDPCanvas extends Canvas implements CommandListener {

    public MIDPCanvas() {
    try {
    // Set up this canvas to listen to command events
    setCommandListener(this);
    // Add the Exit command
    addCommand(new Command("Exit", Command.EXIT, 1));
    } catch(Exception e) {
    e.printStackTrace();
    }
    }

    /**
    * paint
    */
    public void paint(Graphics g) {
    //Set the screen to Fullscreen
    setFullScreenMode(true);
    g.setColor(0x00FFFFFF);
    g.fillRect(0, 0, getWidth(), getHeight());
    Image img=null;
    try {
    //Set the picture
    img = Image.createImage("/picture/Untitled-1.png");
    } catch (IOException ex) {
    ex.printStackTrace();
    }
    g.drawImage(img, getWidth() / 2, getHeight() / 2 - 5, 3);
    try{
    //Set the loading time here. I set it as 1 second (1000 milliseconds)
    Thread.sleep(1000);
    }
    catch(Exception e){
    System.out.println("Error");
    }
    }

    /**
    * Called when a key is pressed.
    */
    protected void keyPressed(int keyCode) {
    }

    /**
    * Called when a key is released.
    */
    protected void keyReleased(int keyCode) {
    }

    /**
    * Called when a key is repeated (held down).
    */
    protected void keyRepeated(int keyCode) {
    }

    /**
    * Called when the pointer is dragged.
    */
    protected void pointerDragged(int x, int y) {
    }

    /**
    * Called when the pointer is pressed.
    */
    protected void pointerPressed(int x, int y) {
    }

    /**
    * Called when the pointer is released.
    */
    protected void pointerReleased(int x, int y) {
    }

    /**
    * Called when action should be handled
    */
    public void commandAction(Command command, Displayable displayable) {
    }

    }

    How to create a password field in J2ME

     // Password field length is set to 9 and the label of the password text field is "Password:"
    private TextField passwd=new TextField("Password:", "", 9, TextField.PASSWORD);

    Code snippet to add images to Lists in J2ME


    try { 
     // Load the images to Image arrays

     image=new Image[]{Image.createImage("/picture/image1.png"), Image.createImage("/picture/image2.png"), Image.createImage("/picture/image3.png")};

     image2=new Image[]{Image.createImage("/picture/search_server.PNG"), Image.createImage("/picture/Calendar.png")};
    }

    catch (IOException ex) {
     ex.printStackTrace(); 
    }

    //Multiple choice Selection
    cri=new List("Select Search Method", List.MULTIPLE, search, image);

    //Implicit Selection
    menu=new List("Select:", List.IMPLICIT, choices, image2);

    2009-09-10

    How to apply styles to the HTML controls by C#.net code

    First, get the reference to the HTML control

    Ex:-LinkButton lb = (LinkButton)Page.FindControl("LinkButton2");

    Then apply the style to the link button by adding the following code

                lb.Attributes.Add("type", "text/css");
                lb.Attributes.Add("rel", "stylesheet");
                lb.Attributes.Add("class", "ph10");

    How to refer to a HTML control from C#.net code

    Lets take the HTML code snippet as follows

    Ex:-<table id="tbData" runat="server">

    Then we can refer to that table from C#.net code by calling the follwing code

    HtmlTable htable = (HtmlTable)Page.FindControl("tbData");

    2009-09-08

    How to add two data fields to a table row in an iPhone application

    @synthesize listData;
    @synthesize ticketNumbers;
    @synthesize sBar;
    @synthesize strJudgeName;
    @synthesize searchedData;

    @synthesize charRegistrationNo;
    @synthesize charTicketNo;

    @synthesize finalTry;
    @synthesize array, array1;
    @synthesize query, statement;

    - (void)viewDidLoad {
       
        listData = [[NSMutableArray alloc] init];        //array which store actual data
        ticketNumbers = [[NSMutableArray alloc] init];    //array which store actual ticket numbers
       
        [listData addObject:@""];
        [listData addObject:@""];
       
        [ticketNumbers addObject:@""];
        [ticketNumbers addObject:@""];
           
        /*NSMutableArray *array = [[NSArray alloc] initWithObjects:@"", @"",
                          @"CD-5646", @"GF-4536", @"GH-6747", @"SF-3425", @"GH-7673", @"DF-3425",
                          @"JX-4343", @"RG-4545", @"FD-3456", @"FG-4556", @"JG-6745", @"FG-5654", @"JH-4356",
                          @"JX-4343", @"BN-4567", @"DF-2356", @"TY-4555", @"GH-4563", nil];
       
        NSMutableArray *array1 = [[NSArray alloc] initWithObjects:@"", @"",
                          @"1002", @"1003", @"1004", @"1005", @"1006", @"1007",
                          @"1034", @"1034", @"1004", @"1004", @"1004", @"1008", @"1006",
                          @"1056", @"1056", @"1034", @"1012", @"1098", nil];*/
       
        array=[[NSMutableArray alloc] init];
        array1=[[NSMutableArray alloc] init];
       
        [array addObjectsFromArray:listData];
        [array1 addObjectsFromArray:ticketNumbers];

           [super viewDidLoad];
       
    }

    - (void)didReceiveMemoryWarning {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];
       
        // Release any cached data, images, etc that aren't in use.
    }

    - (void)viewDidUnload {
        self.listData = nil;
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }


    #pragma mark -
    #pragma mark Table View Data Source Methods

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1;
    }


    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return [array1 count];
    }


    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
       
        static NSString *SimpleTableIdentifier = @"MyIdentifier";
            NSUInteger row = [indexPath row];
       
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
       
       // if (cell == nil) {
    #ifdef __IPHONE_3_0
            // Other styles you can try
            // UITableViewCellStyleSubtitle
            // UITableViewCellStyleValue1
            // UITableViewCellStyleValue2
           
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: SimpleTableIdentifier] autorelease];
    #else
            cell = [[[UITableViewCell alloc] initWithFrame::CGRectZero reuseIdentifier: SimpleTableIdentifier] autorelease];
    #endif
           
            if(row !=0){
            CGRect nameLabelRect = CGRectMake(0, 5, 150, 15);
            UILabel *nameLabel = [[UILabel alloc] initWithFrame:nameLabelRect];
            nameLabel.textAlignment = UITextAlignmentLeft;
            nameLabel.text = @"Ticket No:";
            nameLabel.font = [UIFont boldSystemFontOfSize:14];
            [cell.contentView addSubview: nameLabel];
            [nameLabel release];
       
            CGRect colorLabelRect = CGRectMake(0,26, 150, 15);
            UILabel *colorLabel = [[UILabel alloc] initWithFrame:
                                   colorLabelRect];
            colorLabel.textAlignment = UITextAlignmentLeft;
            colorLabel.text = @"Model No:";
            colorLabel.font = [UIFont boldSystemFontOfSize:14];
            [cell.contentView addSubview: colorLabel];
            [colorLabel release];
           
            CGRect nameValueRect = CGRectMake(150, 5, 200, 15);
            UILabel *nameValue = [[UILabel alloc] initWithFrame:
                                  nameValueRect];
            nameValue.text = [array objectAtIndex:row];
            nameValue.font = [UIFont boldSystemFontOfSize:14];
            [cell.contentView addSubview:nameValue];
            [nameValue release];
           
            CGRect colorValueRect = CGRectMake(150, 25, 200, 15);
            UILabel *colorValue = [[UILabel alloc] initWithFrame:
                                   colorValueRect];
            colorValue.text = [array1 objectAtIndex:row];
            colorValue.font = [UIFont boldSystemFontOfSize:14];
            [cell.contentView addSubview:colorValue];
            [colorValue release];
               
            }
           
       // }
       
        //NSUInteger row = [indexPath row];
        //cell.textLabel.text = [listData objectAtIndex:row];
        //cell.textLabel.font = [UIFont boldSystemFontOfSize:50];
       
    /*#ifdef __IPHONE_3_0   
        if (row < 7)
            cell.detailTextLabel.text = @"Mr. Disney";
        else
            cell.detailTextLabel.text = @"Mr. Tolkein";*/
    //#endif
        return cell;
       
    }


    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

        NSUInteger row = [indexPath row];
        NSString *rowValue = [listData objectAtIndex:row];
       
        //Your code here

    }

    -(NSIndexPath *)tableView:(UITableView *)tableView
     willSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return indexPath;
    }

    - (void)dealloc {
        [array release];
        [ticketNumbers release];
        [array1 release];
        [listData release];
        [super dealloc];
    }


    @end

    Code snippet to create a table and insert values to the table in a sqlite database connection in an iPhone application

             NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
             NSString *documentsDirectory = [paths objectAtIndex:0];
             // Dimo.sqlite3 is the name of the database
             NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Dimo.sqlite3"];
                 
                finalTry=[self dataFilePath];
           
            //  Open the database if already exist or create the database
            if (sqlite3_open([finalTry UTF8String], &database)!= SQLITE_OK) {
                sqlite3_close(database);
                NSAssert(0, @"Failed to open database");
            }

            char *errorMsg;

            // SQL statement
            NSString *createSQL = @"CREATE TABLE IF NOT EXISTS UserAuth (UserId TEXT PRIMARY KEY, Name TEXT, Password TEXT);";

            // Execute the SQL statement
            if (sqlite3_exec (database, [createSQL  UTF8String],
                              NULL, NULL, &errorMsg) != SQLITE_OK) {
                sqlite3_close(database);
                NSAssert1(0, @"Error creating table: %s", errorMsg);
            }
            else{
                char *errorMsg;
                char *update = "INSERT OR REPLACE INTO UserAuth (UserId, Name, Password) VALUES (?, ?, ?);";
                sqlite3_stmt *stmt;
                if (sqlite3_prepare_v2(database, update, -1, &stmt, nil) == SQLITE_OK) {
                   
                    tempUserId=[tempArray objectAtIndex:0];
                    tempUserName=[tempArray objectAtIndex:1];
                    tempPassword=[tempArray objectAtIndex:2];
                   
                    // Question marks of the INSERT SQL queries are replaced with those
                    sqlite3_bind_text(stmt, 1, [tempUserId UTF8String], -1, NULL);
                    sqlite3_bind_text(stmt, 2, [tempUserName UTF8String], -1, NULL);
                    sqlite3_bind_text(stmt, 3, [tempPassword UTF8String], -1, NULL);
                }
                if (sqlite3_step(stmt) != SQLITE_DONE)
                    NSAssert1(0, @"Error updating table: %s", errorMsg);
                sqlite3_finalize(stmt);
            }
           
        }
       
        // Close the database
        sqlite3_close(database);