Outprintlnt balance stnexttoken systemoutprintln else

Info icon This preview shows pages 35–42. Sign up to view the full content.

View Full Document Right Arrow Icon
System.out.println("\t Balance : "+st.nextToken(":")); System.out.println(" "); } } else System.out.println("\tInvalid Id"); } } Execution steps: javac *.java start rmiregistry start java server java client Output:
Image of page 35

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
DS & ADB DCET RAHEEM UNNISA 36 160317742004 9. Implementation of a Remote Object for railway reservation application having a remote method to find status of reservation which when supplied by PNR number. Implement using RMI DATABASE TABLE: Creating Table: Create table mypnr(pnr_id number(10), status varchar(20)); Inserting values into table: Insert into mypnrvalues(1 , ’waiting’); Insert into mypnrvalues(2, ’RAC’); Insert into mypnrvalues(156001, ’RAC’); Executing query: select * from mypnr; Saving Table: commit; PROGRAM: Interface Program: pnrint.java import java.rmi.*; public interface pnrint extends Remote { String getDetails(String id) throws Exception; } Implementation Program: pnrimp.java import java.rmi.server.*;
Image of page 36
DS & ADB DCET RAHEEM UNNISA 37 160317742004 import java.sql.*; public class pnrimp extends UnicastRemoteObject implements pnrint { Connection c; PreparedStatement ps; ResultSet rs; String res,temp; public pnrimp() throws Exception { Class.forName("oracle.jdbc.driver.OracleDriver"); c=DriverManager.getConnection("jdbc:oracle:thin:@ 192.168.2.60:1521:demo”,”scott”,”ti ger” ); } public String getDetails(String id) throws Exception { ps=c.prepareStatement("select * from mypnr where pnr_id=?"); ps.setString(1,id); rs=ps.executeQuery(); if(rs.next()) { res=rs.getString(2)+"::"; System.out.println(res); do { temp=rs.getString(2); res+=temp; } while(rs.next()); return res; } else return "~"; } protected void finalize() throws Throwable
Image of page 37

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
DS & ADB DCET RAHEEM UNNISA 38 160317742004 { c.close(); super.finalize(); } } Server Program: server.java import java.rmi.*; public class server { public static void main(String arg[]) throws Exception { pnrimp obj = new pnrimp(); Naming.rebind("192.168.1.179",obj); } } Client Program: client.java import java.util.*; import java.io.*; import java.rmi.*; public class client { public static void main(String args[])throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String rval; pnrint obj = (pnrint)Naming.lookup("192.168.1.179"); System.out.print("Enter PNR Id : "); rval=obj.getDetails(br.readLine()); System.out.println(rval); if(!rval.equals("~")) { StringTokenizer st = new StringTokenizer(rval,"::");
Image of page 38
DS & ADB DCET RAHEEM UNNISA 39 160317742004 System.out.println("\tPNR Current Status is: "+st.nextToken()); } else System.out.println("\tInvalid PNR ID"); } } Execution steps: javac *.java start rmiregistry start java server java client Output:
Image of page 39

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
DS & ADB DCET RAHEEM UNNISA 40 160317742004 10. Implementation of a railway reservation application having a remote method to find status of reservation which when supplied by PNR number. Implement the above using CORBA. DATABASE TABLE: Creating Table: Create table mypnr(pnr_id number(10), status varchar(20)); Inserting values into table: Insert into mypnrvalues(1 , ’waiting’); Insert into mypnrvalues(2, ’ RAC ’); Insert into mypnrvalues(156001, ’RAC’); Executing query: select * from mypnr; Saving Table: commit; PROGRAM: IDL Program: pnr_intf.idl module pnr { interface pnr_intf { string getStatus(in long id); }; };
Image of page 40
DS & ADB DCET RAHEEM UNNISA 41 160317742004 Implementation Program: implservent.java import pnr.*; import java.sql.*;
Image of page 41

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 42
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern