@@ -0,0 +1,3294 @@
+/*%0A * To change this template, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0A%0A%0Aimport java.net.DatagramPacket;%0Aimport java.net.DatagramSocket;%0Aimport java.net.InetAddress;%0Aimport java.sql.*;%0A%0A/**%0A *%0A * @author Reza Nourbakhsh%0A */%0Apublic class Contact %7B%0A%0A public void ServerProcess()%0A %7B%0A            try%0A                %7B%0A                    String STUNAME=%22%22;%0A                    String ADDRESS=%22%22;%0A                    String POSTCODE=%22%22;%0A                    String EMAIL=%22%22;%0A%0A%0A                    DatagramSocket serverSocket = new DatagramSocket(9875);%0A                    byte%5B%5D receiveData = new byte%5B1024%5D;%0A                    byte%5B%5D sendData = new byte%5B1024%5D;%0A                    while(true)%0A                    %7B%0A                        DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);%0A                        serverSocket.receive(receivePacket);%0A                        String sentence = new String( receivePacket.getData());%0A                        System.out.println(%22RECEIVED:%22 + sentence);%0A                        InetAddress IPAddress = receivePacket.getAddress();%0A                        int port = receivePacket.getPort();%0A                        //Code to retreive data from database%0A%09%09%09%09%09%09boolean FindFlag = false;%0A                        try%0A                        %7B%0A                            String filename = %22STUCONTACT.mdb%22;%0A                            String database = %22jdbc:odbc:Driver=%7BMicrosoft Access Driver (*.mdb)%7D;DBQ=%22;%0A                            database+= filename.trim() ;%0A%0A                            Connection con = DriverManager.getConnection(database,%22%22,%22%22);%0A%0A                            Statement stmt = con.createStatement();%0A%0A                            ResultSet rs = stmt.executeQuery(%22SELECT STUNAME,ADDRESS,POSTCODE,EMAIL FROM Contacts where STUID='%22+sentence.trim()+%22'%22);%0A%0A                            while (rs.next()) %7B%0A%0A                                STUNAME = rs.getString(%22STUNAME%22);%0A                                ADDRESS = rs.getString(%22ADDRESS%22);%0A                                POSTCODE = rs.getString(%22POSTCODE%22);%0A                                EMAIL = rs.getString(%22EMAIL%22);%0A%09%09%09%09%09%09%09    FindFlag = true;%0A                            %7D%0A%0A                        %7D%0A                        catch(Exception e)%0A                        %7B%0A                            System.out.println(%22Error Ocurrs%22);%0A                        %7D%0A                        if(FindFlag == true)%0A                        %7B%0A                    %09    sentence =  STUNAME + ADDRESS + POSTCODE + EMAIL ;%0A%09%09%09%09%09    %7D%0A%09%09%09%09%09    else%0A%09%09%09%09%09    %7B%0A%09%09%09%09%09%09%09sentence =  %22There is no student with this code%22;%0A%09%09%09%09%09%09%7D%0A                        String capitalizedSentence = sentence;%0A%0A                        //************************************************%0A                        sendData = capitalizedSentence.getBytes();%0A                        DatagramPacket sendPacket =%0A                        new DatagramPacket(sendData, sendData.length, IPAddress, port);%0A                        serverSocket.send(sendPacket);%0A                        //************************************************%0A                    %7D%0A                %7D%0A                catch(Exception e)%0A                %7B%0A%0A                %7D%0A%0A            %7D%0A%0A%7D%0A

Create Handler.java