Top Banner
AN APPROACH TO ACCESS THE REMOTE DATABASE FROM MOBILE CLIENTS BAKTAVATCHALAM.G (08MW03) MASTER OF ENGINEERING Branch: SOFTWARE ENGINEERING of Anna University November 2008 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING PSG COLLEGE OF TECHNOLOGY (Autonomous Institution) COIMBATORE – 641 004 Faculty Signature
47

DBMS Project

Nov 18, 2014

Download

Documents

AN APPROACH TO ACCESS THE REMOTE DATABASE FROM
MOBILE CLIENTS
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DBMS Project

AN APPROACH TO ACCESS THE REMOTE DATABASE FROM MOBILE CLIENTS

BAKTAVATCHALAM.G (08MW03)

MASTER OF ENGINEERING

Branch: SOFTWARE ENGINEERING

of Anna University

November 2008

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING PSG COLLEGE OF TECHNOLOGY

(Autonomous Institution)

COIMBATORE – 641 004

Faculty Signature

Page 2: DBMS Project

Acknowledgement

i

ACKNOWLEDGEMENT

We wish to express our sincere gratitude to our respected Principal Dr. R. Rudramoorthy for having given us the opportunity to undertake our project.

We also wish to express our sincere thanks to Dr. S. N. Sivanandam, Professor and Head of the Department of Computer Science and Engineering, for his

encouragement and support that he extends towards our project work.

We extend our sincere thanks to our internal guide, Mrs. R. Bhavani, Lecturer, Department of Computer Science and Engineering, for his guidance and help

rendered for the successful completion of our project.

Page 3: DBMS Project

Contents

iii

CONTENTS

CHAPTER Page No. Synopsis………………….………………………………………………..…………….. .(i) List of Figures.………….………………………………………………...…………….. .(ii) List of Tables.…………………………………………………………………………….(iii) 1. INTRODUCTION.……...…………………………………………………………... .1

1.1. Problem Definition 1

1.2. Objective of the Project 1

1.3. Significance of the Project 1

1.4. Outline of the Project 1

2. SYSTEM STUDY..…….……………………..……………………………………...3 2.1. Proposed System 3

3. SYSTEM ANALYSIS..…….……………………..………………………………….4 3.1 Requirement Analysis 4 3.2 Feasibility Study 4

4. SYSTEM DESIGN…...…….……………………..………………………………….6 4.1 Use case Diagram 6

4.2 Class Diagram 7

4.3 Sequence Diagram 7

4.4 Collaboration Diagram 8

4.5 Activity Diagram 8

4.6 Table Design 9

5. SYSTEM IMPLEMENTATION.………………..…………………………………...10 5.1 Server Module 10

5.2 Mobile Client Module 11

6. TESTING……………………….………………..……………………………………12 6.1 Unit Testing 12

6.2 Integration Testing 14

6.3 Sample Test Cases 15

7. SNAPSHOT.…..……………….………………..…………………………………. 16

7.1 Server 16

Page 4: DBMS Project

Contents

iv

7.2 Mobile Client 16

CONCLUSIONS………………..………………………………………….……….……..17 FUTURE ENHANCEMENTS..…………………………………………………….……. .18

BIBLIOGRAPHY...…………………………………………………………….………….19

APPENDIX…….....…………………………………………………………….………….20

Page 5: DBMS Project

Synopsis

i

SYNOPSIS

In this project, we view the Database remotely from Mobile Terminal

considered as Clients. The Mobile Client sends request to server to view the Database.

Then the Server gets the request and finding out the corresponding Database request

(Query) and processes it.

After retrieving results from Database server optimize the results for

Mobile compatibility and then it will send the result to Mobile Terminal using GPRS. After

mobile got the result it will be displayed to User.

This project is very helpful when anyone need to access some important

information when they out of server site. So the mobile is good device for this type

information access.

Also here Server address is specified each and every time for load

balancing. If one server address may fails then user enter another server address for

Database access. The default Server address always displayed to avoid specifying

manually.

Page 6: DBMS Project

List of Figures

ii

LIST OF FIGURES

FIGURE NO LIST OF FIGURES PAGE NO.

Fig: 2.1

System Architecture 3

Page 7: DBMS Project

List of Tables

iii

LIST OF TABLES

TABLE NO NAME PAGE NO.

Table 4.1 Use case Diagram Elements 6

Table 6.1 Sample Test Cases 15

Page 8: DBMS Project

Introduction Chapter 1

1

CHAPTER 1

INTRODUCTION

This chapter provides a brief overview of the problem definition, objectives and

significance of the project and an outline of the report.

1.1 PROBLEM DEFINITION Accessing the remote database using Mobile Client, the database is accessed

through the Server. The Server handles multiple clients by getting the request from the

clients and process it and reply’s back with the result of the query.

1.2 OBJECTIVE OF THE PROJECT Most of the users are interested in viewing the contents of database using Mobile

Clients. Also users want the information that should be optimized. So this project gives a

solution for user that user can view the required info from anywhere using his Mobile

Terminal.

1.3 SIGNIFICANCE OF THE PROJECT With the enormous growth in information on the database, there is a

corresponding need for tools that enable fast and efficient view of user data.

1.4 OUTLINE OF THE PROJECT The rest of the report is structures as follows. Chapter 2 provides a detailed study

of the existing system and the basic ideas of the proposed system. Chapter 3 discusses

the requirements for the development of the system and an analysis on the feasibility of

Page 9: DBMS Project

Introduction Chapter 1

2

the system. Chapter 4 presents the overall design of the system. Chapter 5 discusses

the implementation details. Chapter 6 explains various testing procedures conducted on

the system. Chapter 7 contains the snapshot of various forms in our system. The last

section summarizes the project.

Page 10: DBMS Project

System Study Chapter 2

3

CHAPTER 2

SYSTEM STUDY

This chapter elucidates the existing system and a brief description of the

proposed system.

2.1 PROPOSED SYSTEM

In our project, we view the Database remotely from Mobile Terminal

considered as Clients. The Mobile Client sends request to server to view the Database.

Then the Server gets the request and finds out the corresponding Database request

(Query). After retrieving results from Database server optimize the results for Mobile

compatible then it will send the result to Mobile Terminal using GPRS. After mobile got

the result it will be displayed to User. This project is very helpful when anyone need to

access some important information when they are out of server site. So the mobile is

good device for this type information access. Also here Server address is specified each

and every time for load balancing. If one server address may fails then user enter

another server address for Database access. The default Server address always

displayed to avoid specifying manually.

Figure 2.1

Server

Client - 1

Client - 2

Client - n

Display Optimized

Output

Database

Page 11: DBMS Project

System Analysis Chapter 3

4

CHAPTER 3

SYSTEM ANALYSIS This section describes the hardware and software specifications for the

development of the system and an analysis on the feasibility of the system.

3.1 REQUIREMENT ANALYSIS 3.1.1 Software Requirements After experimenting with various commercial software available and analyzing

the Pros and Cons of the software, the following are chosen.

• Operating System – Platform Independent • Programming Languages – Java 1.6+ • Front End – J2ME

3.1.2 Hardware Requirements The Hardware requirements of the proposed system are as follows:

• Pentium-III machine & above

• RAM-256 MB

• Hard Disk with a Capacity of 10 GB 3.2 FEASIBILITY ANALYSIS Feasibility deals with step-by-step analysis of the system. Analysis showed that

this project was feasible in all respects. Three kinds of feasibility factors are considered:

• Economic Feasibility

• Technical Feasibility

• Operational Feasibility

Page 12: DBMS Project

System Analysis Chapter 3

5

3.2.1 Economic Feasibility

The system is developed only using those softwares that are very well used in

the market, so there is no need for installation of new softwares. Hence, the cost

incurred towards this project is negligible

3.2.2 Technical Feasibility

3.2.2.1 Searching The main aim of our project is to search a specific set of keywords in a specific

set of websites only.

3.2.2.2 Distributed Searching Next important thing that must be done in our project is to process the searching

in distributed manner. So the searching is run concurrently in all client systems and

server combine this result and produce final result.

3.2.3 Operational Feasibility The functions needed to be performed by the system are all valid and without

any conflicts. All functions and constraints specified in the requirements are completely

operational. The requirements stated are realistically testable.

The requirements are adaptable to changes with out any large-scale effects on

other system requirements. The system is capable of accommodating future

requirements if they arise.

Page 13: DBMS Project

System Design Chapter 4

6

CHAPTER 4

SYSTEM DESIGN This chapter describes the functional decomposition of the system and illustrates

the movement of data between external entities, the processes and the data stores

within the system, with the help of data flow diagrams.

4.1 USE CASE DIAGRAM

Actors DB,Mobile Client, Server

Usecases Required Info,Res Info,Quering, Query Results

Required Information

Querying

DBResults

Server

Info

Mobile Client

Page 14: DBMS Project

System Design Chapter 4

7

4.2 CLASS DIAGRAM

MClientIP : StringServerAddr : StringreqInfo : String

makeConn(seraddr : String)sendReq(req : String)getResults() : Stringdisp()

Server_port : intmax_con : int

getReq(req : String)sendQry(q : String)sendRes(res : String)getRes()

DB_

getQry(q : String)sendRes(res : String)

4.3 SEQUENCE DIAGRAM

Mclient Server DB

1: Req Info2: Find Query

3: ReqQuery

4: Process

5: Query Result

6: Format

7: Send Info

8: Display

Page 15: DBMS Project

System Design Chapter 4

8

4.4 COLLABORATION DIAGRAM

Mclient Server DB

2: Find Query4: Process6: Format8: Display

1: Req Info

7: Send Info

3: ReqQuery

5: Query Result

4.5 STATE CHART / ACTIVITY DIAGRAM

send Req

Get Info & Display

Process Req & get corresponding Query

Send Query

Result Refining

Formatted Info

Process Query & Send Results

DBServ erMClient

Page 16: DBMS Project

System Design Chapter 4

9

4.6 TABLE DESIGN E-R Diagram:

TABLES:

Customer CID CNAME CADDR

Product PID PNAME UCOST INVENTORY VID

Vendor VID VNAME VADDR PID

Order OID CID ODATE PID QTY

CID

CUSTOMER

CNAME CADDR

PRODUCT

PID PNAME UCOST

INVENTORY

VID

VENDOR PID

SUPPLIES

VID VNAME

VADDR

ORDER

OID ODATE QTY

Page 17: DBMS Project

Implementation Chapter 5

10

CHAPTER 5

IMPLEMENTATION

This phase is broken up into two phases: Development and Implementation. The

individual system components are built during the development period. Programs are

written and tried by users.

During Implementation, the components built during development are put into

operational use.

In the development phase of our system, the following system components were

built.

• Server module

• Mobile Client module

The Server & Client module is developed using Java & Java Swings.

5.1 Server Module This module contains following sub-modules,

• Client Listening Module

• DB Connectivity Module

• Result Formatter Module

5.1.1 Client Listening Module In this module we create separate threads for each clients and the corresponding

client will communicate only through that Thread.

5.1.2 DB Connectivity Module In this module we make/select appropriate DB Query according to the Mobile

Client Request and make DB connection and run the Query then retrieve the Query

Results.

5.1.3 Result Formatter Module In this module we display format the result into mobile client acceptable format.

Page 18: DBMS Project

Implementation Chapter 5

11

5.2 Mobile Client Module This module contains following sub-modules,

• Load Module

• Connection Management Module

• Display Module

5.2.1 Load Module In this module we get the appropriate request option from the user.

5.2.1 Connection Management Module Whenever user request for info we make socket connections to the server. Also

this do the sending/receiving data to/from server.

5.2.1 Display Module After info is gathered from server it is then displayed to the user.

Page 19: DBMS Project

Testing Chapter 6

12

CHAPTER 6

TESTING

This chapter explains the various testing procedures conducted on the system.

Testing is a process of executing a program with the intent of finding an error. A

successful test is one that uncovers an as yet undiscovered error. A testing process

cannot show the absence of defects but can only show that software errors are present.

It ensures that defined input will produce actual results that agree with the required

results. A good testing methodology should include

• Clearly define testing roles, responsibilities and procedures

• Establish consistent testing process

• Streamline testing requirements

• Overcome “requirements slow me down” mentality

• Common sense process approach

• Use some elements of existing Process

• Not an attempt to replace, rewrite or redefine Process

• To find defects early and to give good time to developers for bug fixes

• Independent perspective in testing

Some of the testing principles used in this project are:

• Unit Testing

• Integration Testing

6.1 UNIT TESTING Unit testing is a strategy by which individual components, which make up the

system, are tested first to ensure that system works up to the desired extent. It focuses

on the verification effort on the smallest unit of the software design i.e. module. Various

modules of the system are tested to see whether they perform their intended functions.

Using procedural design description, important control paths are tested to uncover the

Page 20: DBMS Project

Testing Chapter 6

13

errors with in the boundary of the module. While accepting a connection using specified

functions we go for unit testing in their respective modules. The unit test is normally a

white box test (a testing method in which the control structure of the procedural design is

used to derive test cases).

6.1.1 Process Objectives To test every unit of the software in isolation before integrating it with other units.

6.1.2 Definition of Unit

A unit is a module as identified during size estimation process with a size

estimate that does not exceed 1000LOC.

For GUI applications each screen will be a unit.

If the size estimate for a unit exceeds 1000 LOC and it is not feasible to break it

into smaller logically independent units that can be tested in isolation, the project lead in

concurrence with the SQA can decide to define this as a unit.

6.1.3 Entry Criteria The entry criteria for this process are the following:

• Unit completed

• Unit peer reviewed

6.1.4 Exit Criteria The exit criteria for this process are the following:

• Unit test cases executed

• Any defects that are identified during unit testing and that are not fixed before the

unit enters component testing is listed in the test report and verified

• 100% statement coverage

If unit will be tested before code review of unit, this must be identified in the

project plan. In these projects the developer will self-review (desk check) the code

before unit testing.

In cases of exception handling of error conditions that are difficult to generate,

thereby making it impossible to achieve 100% statement coverage, the code should be

formally reviewed with this additional criteria

Page 21: DBMS Project

Testing Chapter 6

14

6.2 INTEGRATION TESTING The integration testing is a systematic technique for constructing the program

structure while conducting tests to uncover errors associated with interfacing. It is a type

of testing by which the individual modules of the system are combined and tested

whether they work properly as a whole. The objective is to take unit test modules and

build a program that has been dictated by the design. Integration testing can be either

‘Incremental’ or ‘Non-Incremental’.

The objective of the integration testing is to help engineers plan and execute the

component and Integration testing for their respective projects.

Integration testing should include the following objectives:

• Performed by the product group/Dev test team after feature complete

• Determines that all product components on a list of specific platforms function

successfully together (The List specified in Master test plan)

• Performed in a basic product / platform environment (Basic environment

specified in Master test plan)

• Tests the product functionality against the specification

• Tests functionality of fake languages with sample single and double byte

languages

• Tests scaling to an acceptable minimum level as called out in the master test

plan

• Tests performance, reliability to an acceptable level as called out in the master

test plan

• Final integration tests done after all components are integrated, with the build in

production format

The tasks of the project have been integrated and the functioning of the entire

system has been found to be satisfactory. The functionality of the entire system has

been subjected to a series of tests and all the modules have been found to interoperate

properly.

Finally the integration testing was performed on the integrated system and found

to work properly.

Page 22: DBMS Project

Testing Chapter 6

15

6.3 SAMPLE TEST CASES The following are the some of the sample test cases employed along with the

test results have been described in the table below.

Table 6.1 Sample Test Cases

Test Description

Result

Is Server stable for running more than one clients? OK

Is Clients are return the results properly? OK

Is Client using the Internet Optimally? OK

Is Server DB Connectivity is Optimal? OK

Is Client takes Lower Resources? OK

Page 23: DBMS Project

Snapshot Chapter 7

16

CHAPTER 7

SNAPSHOT

This chapter contains the snapshot of various forms in our system.

7.1 Server

Page 24: DBMS Project

Snapshot Chapter 7

17

7.2 Client (When Searching Process)

Page 25: DBMS Project

Conclusion

17

CONCLUSION

Thus the analysis, design and implementation of mobile database views are

done successfully. So that the users can able to view the database as they wants and

also the server give better results when number of mobile client requests are increased.

Page 26: DBMS Project

Future Enhancements

18

FUTURE ENHANCEMENTS Currently we need GPRS for Mobile clients, Due to Hardware Limitations

currently we can only view Database Contents, and results from Server are limited. In

future improvements are the communication between Mobile Terminal and Server

extended with other Network Technologies like Bluetooth, Infrared…Abilities for

modifying the database, and retrieves more results from Server.

Page 27: DBMS Project

Bibliography

19

BIBLIOGRAPHY

• J2ME Complete Reference

• Java Network Programming, O'Reilly & Associates, Inc.,, Second Edition

• Herbert Schildt ., and Patrick Naughton , 2001,“Java2: The Complete Reference “, Fourth Edition , Tata McGraw-Hill Publishing Company Limited .

Websites

http://ibm.com/developerWorks

Page 28: DBMS Project

Appendix

20

APPENDIX

SOURCE CODE LISTINGS

This chapter provides source code listings.

OUTPUT (In Server)

Socket[addr=/127.0.0.1,port=1046,localport=6776] Connected.

ID:1

Data Sent:[[B@6ca1c]

Connection Closed.

Socket[addr=/127.0.0.1,port=1047,localport=6776] Connected.

ID:1

Data:

VendorID:1

VendorName:v1

VendorAddr:va1

ProductID:1

Data Sent:[[B@5740bb]

Connection Closed.

SERVER

public class Start { public static void main(String[] aa) { new Server(); } } //////////// import java.io.*; import java.net.*; public class Server implements SharedInterface

Page 29: DBMS Project

Appendix

21

{ public Server() { new ServerListener(this); } public void newClient(Socket s) { infoMsg(s.toString()+" Connected."); new ClientThread(this,s); } public void errorMsg(String msg) { System.out.println(msg); } public void infoMsg(String msg) { System.out.println(msg); } } ////////////// import java.net.*; import java.io.*; import java.sql.*; public class ClientThread extends Thread { Socket S=null; SharedInterface SI=null; public InputStream in=null; public OutputStream out=null; public ClientThread(SharedInterface si,Socket s) { SI=si; S=s; start(); } public String getDBData(int opt,String dt,int id) { String sss=""; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:gmb"); Statement st=con.createStatement(); ResultSet rs=null; switch(opt) { case 1: rs=st.executeQuery("select * from OrderForm where odate='"+dt+"'");

Page 30: DBMS Project

Appendix

22

while (rs.next()) { sss+="OrderID:"+rs.getInt(1)+"\nCustID:"+rs.getInt(2)+"\nDate:"+rs.getString(3)+"\nProductID:"+rs.getInt(4)+"\nQty:"+rs.getInt(5)+"\nTotalCost:"+rs.getInt(6); } break; case 2: rs=st.executeQuery("select * from OrderForm where cid="+id); while (rs.next()) { sss+="\nOrderID:"+rs.getInt(1)+"\nCustID:"+rs.getInt(2)+"\nDate:"+rs.getString(3)+"\nProductID:"+rs.getInt(4)+"\nQty:"+rs.getInt(5)+"\nTotalCost:"+rs.getInt(6); } break; case 3: rs=st.executeQuery("select * from Vendor where vid="+id); while (rs.next()) { sss+="\nVendorID:"+rs.getInt(1)+"\nVendorName:"+rs.getString(2)+"\nVendorAddr:"+rs.getString(3)+"\nProductID:"+rs.getInt(4); } break; case 4: rs=st.executeQuery("select * from Customer where cid="+id); while (rs.next()) { sss+="\nCustID:"+rs.getInt(1)+"\nCustName:"+rs.getString(2)+"\nCustAddr:"+rs.getString(3); } break; case 5: rs=st.executeQuery("select * from Product where pid="+id); while (rs.next()) { sss+="\nProductID:"+rs.getInt(1)+"\nProductName:"+rs.getString(2)+"\nUnitCost:"+rs.getInt(3)+"\nInventory:"+rs.getInt(4)+"\nVendorID:"+rs.getInt(5); } break; } rs.close(); st.close(); con.close(); } catch(Exception e1) { sss="SQL Error:"+e1.getMessage(); }

Page 31: DBMS Project

Appendix

23

return sss; } public void run() { try { in=S.getInputStream(); BufferedReader in1=new BufferedReader(new InputStreamReader(in)); out=S.getOutputStream(); PrintStream out1=new PrintStream(out); DataOutputStream out2=new DataOutputStream(out); String rs=""; int cond=0; String dt=""; int tmP=0; int id=0; int opt=in.read(); if(opt==1) { dt=in1.readLine(); SI.infoMsg(dt); rs=getDBData(opt,dt,id); SI.infoMsg(rs); out1.write(rs.getBytes()); } else { id=in.read(); SI.infoMsg("ID:"+id); rs=getDBData(opt,dt,id); SI.infoMsg("Data:\n"+rs); out1.write(rs.getBytes()); } in.close(); out.close(); out1.close(); SI.infoMsg("Data Sent:["+rs.getBytes()+"]\n Connection Closed."); } catch(Exception e2) { SI.errorMsg("Client Data Write Error:"+e2.getMessage()); } } } /////////// import java.net.*; import java.io.*; public class ServerListener extends Thread { SharedInterface SI=null; ServerSocket SS=null; int port=0;

Page 32: DBMS Project

Appendix

24

boolean tF=false; public ServerListener(SharedInterface si) { SI=si; port=SI.PORT; tF=false; start(); } public void terminate() { tF=true; } public void run() { try { SS=new ServerSocket(port); while(tF==false) { SI.newClient(SS.accept()); } } catch(Exception e1) { SI.errorMsg("Server Listener Error:"+e1.getMessage()); } } } //////////////// import java.net.*; public interface SharedInterface { public final int PORT=6776; public void newClient(Socket s); public void errorMsg(String msg); public void infoMsg(String msg); }

MOBILE CLIENT

import java.io.DataInputStream; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import javax.microedition.io.Connector; import javax.microedition.io.SocketConnection; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; /**

Page 33: DBMS Project

Appendix

25

* @author SuperStar */ public class VisualMIDlet extends MIDlet implements DBI,CommandListener,ItemCommandListener { private boolean midletPaused = false; // String IP="127.0.0.1"; private int opt=0; private String rs="",lbl=""; private String dt=""; private int id=0; // //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0| private java.util.Hashtable __previousDisplayables = new java.util.Hashtable(); private Form form; private ImageItem imageItem; private StringItem stringItem; private StringItem stringItem1; private Form form1; private TextField textField; private Form form2; private ChoiceGroup choiceGroup; private Form form3; private TextField textField1; private Form form4; private StringItem stringItem2; private Command exitCommand; private Command okCommand; private Command cancelCommand; private Command okCommand1; private Command cancelCommand1; private Command backCommand; private Command backCommand1; private Command okCommand3; private Command exitCommand1; private Command okCommand5; private Command okCommand2; private Image image1; //</editor-fold>//GEN-END:|fields|0| /** * The VisualMIDlet constructor. */ public VisualMIDlet() { } //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0| /** * Switches a display to previous displayable of the current displayable.

Page 34: DBMS Project

Appendix

26

* The <code>display</code> instance is obtain from the <code>getDisplay</code> method. */ private void switchToPreviousDisplayable() { Displayable __currentDisplayable = getDisplay().getCurrent(); if (__currentDisplayable != null) { Displayable __nextDisplayable = (Displayable) __previousDisplayables.get(__currentDisplayable); if (__nextDisplayable != null) { switchDisplayable(null, __nextDisplayable); } } } //</editor-fold>//GEN-END:|methods|0| //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize /** * Initilizes the application. * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method. */ private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize // write pre-initialize user code here //GEN-LINE:|0-initialize|1|0-postInitialize // write post-initialize user code here }//GEN-BEGIN:|0-initialize|2| //</editor-fold>//GEN-END:|0-initialize|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction /** * Performs an action assigned to the Mobile Device - MIDlet Started point. */ public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction // write pre-action user code here switchDisplayable(null, getForm());//GEN-LINE:|3-startMIDlet|1|3-postAction // write post-action user code here }//GEN-BEGIN:|3-startMIDlet|2| //</editor-fold>//GEN-END:|3-startMIDlet|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction /** * Performs an action assigned to the Mobile Device - MIDlet Resumed point. */ public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction // write pre-action user code here //GEN-LINE:|4-resumeMIDlet|1|4-postAction // write post-action user code here }//GEN-BEGIN:|4-resumeMIDlet|2| //</editor-fold>//GEN-END:|4-resumeMIDlet|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch /**

Page 35: DBMS Project

Appendix

27

* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable. * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately * @param nextDisplayable the Displayable to be set */ public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch // write pre-switch user code here Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch Displayable __currentDisplayable = display.getCurrent(); if (__currentDisplayable != null && nextDisplayable != null) { __previousDisplayables.put(nextDisplayable, __currentDisplayable); } if (alert == null) { display.setCurrent(nextDisplayable); } else { display.setCurrent(alert, nextDisplayable); }//GEN-END:|5-switchDisplayable|1|5-postSwitch // write post-switch user code here }//GEN-BEGIN:|5-switchDisplayable|2| //</editor-fold>//GEN-END:|5-switchDisplayable|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|23-getter|0|23-preInit /** * Returns an initiliazed instance of form component. * @return the initialized component instance */ public Form getForm() { if (form == null) {//GEN-END:|23-getter|0|23-preInit // write pre-init user code here form = new Form("SuperStar DB", new Item[] { getStringItem1(), getImageItem(), getStringItem() });//GEN-BEGIN:|23-getter|1|23-postInit form.addCommand(getExitCommand()); form.addCommand(getOkCommand()); form.setCommandListener(this);//GEN-END:|23-getter|1|23-postInit // write post-init user code here }//GEN-BEGIN:|23-getter|2| return form; } //</editor-fold>//GEN-END:|23-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: imageItem ">//GEN-BEGIN:|27-getter|0|27-preInit /** * Returns an initiliazed instance of imageItem component. * @return the initialized component instance */ public ImageItem getImageItem() { if (imageItem == null) {//GEN-END:|27-getter|0|27-preInit // write pre-init user code here imageItem = new ImageItem("Welcome To PSG College of Technology", getImage1(), ImageItem.LAYOUT_DEFAULT, "<Missing Image>", Item.PLAIN);//GEN-LINE:|27-getter|1|27-postInit

Page 36: DBMS Project

Appendix

28

// write post-init user code here }//GEN-BEGIN:|27-getter|2| return imageItem; } //</editor-fold>//GEN-END:|27-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: image1 ">//GEN-BEGIN:|28-getter|0|28-preInit /** * Returns an initiliazed instance of image1 component. * @return the initialized component instance */ public Image getImage1() { if (image1 == null) {//GEN-END:|28-getter|0|28-preInit // write pre-init user code here try {//GEN-BEGIN:|28-getter|1|[email protected] image1 = Image.createImage("/PSG (Custom).JPG"); } catch (java.io.IOException e) {//GEN-END:|28-getter|1|[email protected] e.printStackTrace(); }//GEN-LINE:|28-getter|2|28-postInit // write post-init user code here }//GEN-BEGIN:|28-getter|3| return image1; } //</editor-fold>//GEN-END:|28-getter|3| //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction /** * Called by a system to indicated that a command has been invoked on a particular displayable. * @param command the Command that was invoked * @param displayable the Displayable where the command was invoked */ public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction // write pre-action user code here if (displayable == form) {//GEN-BEGIN:|7-commandAction|1|30-preAction if (command == exitCommand) {//GEN-END:|7-commandAction|1|30-preAction // write pre-action user code here exitMIDlet();//GEN-LINE:|7-commandAction|2|30-postAction // write post-action user code here } else if (command == okCommand) {//GEN-LINE:|7-commandAction|3|33-preAction // write pre-action user code here switchDisplayable(null, getForm1());//GEN-LINE:|7-commandAction|4|33-postAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|5|40-preAction } else if (displayable == form1) { if (command == cancelCommand) {//GEN-END:|7-commandAction|5|40-preAction // write pre-action user code here switchDisplayable(null, getForm());//GEN-LINE:|7-commandAction|6|40-postAction // write post-action user code here

Page 37: DBMS Project

Appendix

29

} else if (command == okCommand1) {//GEN-LINE:|7-commandAction|7|38-preAction // write pre-action user code here IP=textField.getString(); switchDisplayable(null, getForm2());//GEN-LINE:|7-commandAction|8|38-postAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|9|53-preAction } else if (displayable == form2) { if (command == cancelCommand1) {//GEN-END:|7-commandAction|9|53-preAction // write pre-action user code here switchDisplayable(null, getForm());//GEN-LINE:|7-commandAction|10|53-postAction // write post-action user code here } else if (command == okCommand5) {//GEN-LINE:|7-commandAction|11|90-preAction // write pre-action user code here if (choiceGroup.getSelectedIndex()==-1) opt=2; else opt=choiceGroup.getSelectedIndex()+1; if(opt==1) lbl=("Enter Date [DD-MM-YYYY]:"); else if(opt==2) lbl=("Enter Order ID:"); else if(opt==3) lbl=("Enter Vendor ID:"); else if(opt==4) lbl=("Enter Customer ID:"); else lbl=("Enter Product ID:"); switchDisplayable(null, getForm3());//GEN-LINE:|7-commandAction|12|90-postAction // write post-action user code here textField1.setLabel(lbl); }//GEN-BEGIN:|7-commandAction|13|63-preAction } else if (displayable == form3) { if (command == backCommand) {//GEN-END:|7-commandAction|13|63-preAction // write pre-action user code here switchToPreviousDisplayable();//GEN-LINE:|7-commandAction|14|63-postAction // write post-action user code here } else if (command == okCommand3) {//GEN-LINE:|7-commandAction|15|66-preAction // write pre-action user code here id=1; dt="10-10-00"; if(opt==1) dt=textField1.getString(); else id=Integer.parseInt(textField1.getString()); switchDisplayable(null, getForm4());//GEN-LINE:|7-commandAction|16|66-postAction

Page 38: DBMS Project

Appendix

30

// write post-action user code here DB db=new DB(IP, opt, dt, id,this); }//GEN-BEGIN:|7-commandAction|17|72-preAction } else if (displayable == form4) { if (command == backCommand1) {//GEN-END:|7-commandAction|17|72-preAction // write pre-action user code here switchDisplayable(null, getForm2());//GEN-LINE:|7-commandAction|18|72-postAction // write post-action user code here } else if (command == exitCommand1) {//GEN-LINE:|7-commandAction|19|74-preAction // write pre-action user code here exitMIDlet();//GEN-LINE:|7-commandAction|20|74-postAction // write post-action user code here } else if (command == okCommand2) {//GEN-LINE:|7-commandAction|21|93-preAction // write pre-action user code here //GEN-LINE:|7-commandAction|22|93-postAction // write post-action user code here stringItem2.setText(rs); }//GEN-BEGIN:|7-commandAction|23|7-postCommandAction }//GEN-END:|7-commandAction|23|7-postCommandAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|24| //</editor-fold>//GEN-END:|7-commandAction|24| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|29-getter|0|29-preInit /** * Returns an initiliazed instance of exitCommand component. * @return the initialized component instance */ public Command getExitCommand() { if (exitCommand == null) {//GEN-END:|29-getter|0|29-preInit // write pre-init user code here exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|29-getter|1|29-postInit // write post-init user code here }//GEN-BEGIN:|29-getter|2| return exitCommand; } //</editor-fold>//GEN-END:|29-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|32-getter|0|32-preInit /** * Returns an initiliazed instance of okCommand component. * @return the initialized component instance */ public Command getOkCommand() { if (okCommand == null) {//GEN-END:|32-getter|0|32-preInit // write pre-init user code here okCommand = new Command("Ok", Command.OK, 0);//GEN-LINE:|32-getter|1|32-postInit // write post-init user code here

Page 39: DBMS Project

Appendix

31

}//GEN-BEGIN:|32-getter|2| return okCommand; } //</editor-fold>//GEN-END:|32-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form1 ">//GEN-BEGIN:|34-getter|0|34-preInit /** * Returns an initiliazed instance of form1 component. * @return the initialized component instance */ public Form getForm1() { if (form1 == null) {//GEN-END:|34-getter|0|34-preInit // write pre-init user code here form1 = new Form("Student DB", new Item[] { getTextField() });//GEN-BEGIN:|34-getter|1|34-postInit form1.addCommand(getOkCommand1()); form1.addCommand(getCancelCommand()); form1.setCommandListener(this);//GEN-END:|34-getter|1|34-postInit // write post-init user code here }//GEN-BEGIN:|34-getter|2| return form1; } //</editor-fold>//GEN-END:|34-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField ">//GEN-BEGIN:|36-getter|0|36-preInit /** * Returns an initiliazed instance of textField component. * @return the initialized component instance */ public TextField getTextField() { if (textField == null) {//GEN-END:|36-getter|0|36-preInit // write pre-init user code here textField = new TextField("Enter Server IP:", "127.0.0.1", 32, TextField.ANY);//GEN-LINE:|36-getter|1|36-postInit // write post-init user code here }//GEN-BEGIN:|36-getter|2| return textField; } //</editor-fold>//GEN-END:|36-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">//GEN-BEGIN:|37-getter|0|37-preInit /** * Returns an initiliazed instance of okCommand1 component. * @return the initialized component instance */ public Command getOkCommand1() { if (okCommand1 == null) {//GEN-END:|37-getter|0|37-preInit // write pre-init user code here okCommand1 = new Command("Ok", Command.OK, 0);//GEN-LINE:|37-getter|1|37-postInit // write post-init user code here }//GEN-BEGIN:|37-getter|2|

Page 40: DBMS Project

Appendix

32

return okCommand1; } //</editor-fold>//GEN-END:|37-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand ">//GEN-BEGIN:|39-getter|0|39-preInit /** * Returns an initiliazed instance of cancelCommand component. * @return the initialized component instance */ public Command getCancelCommand() { if (cancelCommand == null) {//GEN-END:|39-getter|0|39-preInit // write pre-init user code here cancelCommand = new Command("Cancel", Command.CANCEL, 0);//GEN-LINE:|39-getter|1|39-postInit // write post-init user code here }//GEN-BEGIN:|39-getter|2| return cancelCommand; } //</editor-fold>//GEN-END:|39-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form2 ">//GEN-BEGIN:|42-getter|0|42-preInit /** * Returns an initiliazed instance of form2 component. * @return the initialized component instance */ public Form getForm2() { if (form2 == null) {//GEN-END:|42-getter|0|42-preInit // write pre-init user code here form2 = new Form("Select Option", new Item[] { getChoiceGroup() });//GEN-BEGIN:|42-getter|1|42-postInit form2.addCommand(getCancelCommand1()); form2.addCommand(getOkCommand5()); form2.setCommandListener(this);//GEN-END:|42-getter|1|42-postInit // write post-init user code here }//GEN-BEGIN:|42-getter|2| return form2; } //</editor-fold>//GEN-END:|42-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: choiceGroup ">//GEN-BEGIN:|44-getter|0|44-preInit /** * Returns an initiliazed instance of choiceGroup component. * @return the initialized component instance */ public ChoiceGroup getChoiceGroup() { if (choiceGroup == null) {//GEN-END:|44-getter|0|44-preInit // write pre-init user code here choiceGroup = new ChoiceGroup("Query", Choice.POPUP);//GEN-BEGIN:|44-getter|1|44-postInit choiceGroup.append("View Product Sales For a Day", null); choiceGroup.append("View Orders For a Single Customer", null); choiceGroup.append("View Vendor Details", null); choiceGroup.append("View Customer Details", null);

Page 41: DBMS Project

Appendix

33

choiceGroup.append("View Product Details", null); choiceGroup.setItemCommandListener(this); choiceGroup.setSelectedFlags(new boolean[] { true, false, false, false, false }); choiceGroup.setFont(0, null); choiceGroup.setFont(1, null); choiceGroup.setFont(2, null); choiceGroup.setFont(3, null); choiceGroup.setFont(4, null);//GEN-END:|44-getter|1|44-postInit // write post-init user code here }//GEN-BEGIN:|44-getter|2| return choiceGroup; } //</editor-fold>//GEN-END:|44-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand1 ">//GEN-BEGIN:|52-getter|0|52-preInit /** * Returns an initiliazed instance of cancelCommand1 component. * @return the initialized component instance */ public Command getCancelCommand1() { if (cancelCommand1 == null) {//GEN-END:|52-getter|0|52-preInit // write pre-init user code here cancelCommand1 = new Command("Cancel", Command.CANCEL, 0);//GEN-LINE:|52-getter|1|52-postInit // write post-init user code here }//GEN-BEGIN:|52-getter|2| return cancelCommand1; } //</editor-fold>//GEN-END:|52-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form3 ">//GEN-BEGIN:|57-getter|0|57-preInit /** * Returns an initiliazed instance of form3 component. * @return the initialized component instance */ public Form getForm3() { if (form3 == null) {//GEN-END:|57-getter|0|57-preInit // write pre-init user code here form3 = new Form("Enter Details:", new Item[] { getTextField1() });//GEN-BEGIN:|57-getter|1|57-postInit form3.addCommand(getBackCommand()); form3.addCommand(getOkCommand3()); form3.setCommandListener(this);//GEN-END:|57-getter|1|57-postInit // write post-init user code here }//GEN-BEGIN:|57-getter|2| return form3; } //</editor-fold>//GEN-END:|57-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField1 ">//GEN-BEGIN:|61-getter|0|61-preInit /**

Page 42: DBMS Project

Appendix

34

* Returns an initiliazed instance of textField1 component. * @return the initialized component instance */ public TextField getTextField1() { if (textField1 == null) {//GEN-END:|61-getter|0|61-preInit // write pre-init user code here textField1 = new TextField("Value:", "0", 32, TextField.ANY);//GEN-LINE:|61-getter|1|61-postInit // write post-init user code here }//GEN-BEGIN:|61-getter|2| return textField1; } //</editor-fold>//GEN-END:|61-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form4 ">//GEN-BEGIN:|67-getter|0|67-preInit /** * Returns an initiliazed instance of form4 component. * @return the initialized component instance */ public Form getForm4() { if (form4 == null) {//GEN-END:|67-getter|0|67-preInit // write pre-init user code here form4 = new Form("Output", new Item[] { getStringItem2() });//GEN-BEGIN:|67-getter|1|67-postInit form4.addCommand(getBackCommand1()); form4.addCommand(getExitCommand1()); form4.addCommand(getOkCommand2()); form4.setCommandListener(this);//GEN-END:|67-getter|1|67-postInit // write post-init user code here }//GEN-BEGIN:|67-getter|2| return form4; } //</editor-fold>//GEN-END:|67-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|62-getter|0|62-preInit /** * Returns an initiliazed instance of backCommand component. * @return the initialized component instance */ public Command getBackCommand() { if (backCommand == null) {//GEN-END:|62-getter|0|62-preInit // write pre-init user code here backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|62-getter|1|62-postInit // write post-init user code here }//GEN-BEGIN:|62-getter|2| return backCommand; } //</editor-fold>//GEN-END:|62-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand3 ">//GEN-BEGIN:|65-getter|0|65-preInit /** * Returns an initiliazed instance of okCommand3 component.

Page 43: DBMS Project

Appendix

35

* @return the initialized component instance */ public Command getOkCommand3() { if (okCommand3 == null) {//GEN-END:|65-getter|0|65-preInit // write pre-init user code here okCommand3 = new Command("Ok", Command.OK, 0);//GEN-LINE:|65-getter|1|65-postInit // write post-init user code here }//GEN-BEGIN:|65-getter|2| return okCommand3; } //</editor-fold>//GEN-END:|65-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 ">//GEN-BEGIN:|71-getter|0|71-preInit /** * Returns an initiliazed instance of backCommand1 component. * @return the initialized component instance */ public Command getBackCommand1() { if (backCommand1 == null) {//GEN-END:|71-getter|0|71-preInit // write pre-init user code here backCommand1 = new Command("Back", Command.BACK, 0);//GEN-LINE:|71-getter|1|71-postInit // write post-init user code here }//GEN-BEGIN:|71-getter|2| return backCommand1; } //</editor-fold>//GEN-END:|71-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 ">//GEN-BEGIN:|73-getter|0|73-preInit /** * Returns an initiliazed instance of exitCommand1 component. * @return the initialized component instance */ public Command getExitCommand1() { if (exitCommand1 == null) {//GEN-END:|73-getter|0|73-preInit // write pre-init user code here exitCommand1 = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|73-getter|1|73-postInit // write post-init user code here }//GEN-BEGIN:|73-getter|2| return exitCommand1; } //</editor-fold>//GEN-END:|73-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|77-getter|0|77-preInit /** * Returns an initiliazed instance of stringItem component. * @return the initialized component instance */

Page 44: DBMS Project

Appendix

36

public StringItem getStringItem() { if (stringItem == null) {//GEN-END:|77-getter|0|77-preInit // write pre-init user code here stringItem = new StringItem("Developed By", "G.BAKTAVATCHALAM (08MW03)");//GEN-LINE:|77-getter|1|77-postInit // write post-init user code here }//GEN-BEGIN:|77-getter|2| return stringItem; } //</editor-fold>//GEN-END:|77-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem1 ">//GEN-BEGIN:|78-getter|0|78-preInit /** * Returns an initiliazed instance of stringItem1 component. * @return the initialized component instance */ public StringItem getStringItem1() { if (stringItem1 == null) {//GEN-END:|78-getter|0|78-preInit // write pre-init user code here stringItem1 = new StringItem("DBMS For", "Product Sales Management");//GEN-LINE:|78-getter|1|78-postInit // write post-init user code here }//GEN-BEGIN:|78-getter|2| return stringItem1; } //</editor-fold>//GEN-END:|78-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand5 ">//GEN-BEGIN:|89-getter|0|89-preInit /** * Returns an initiliazed instance of okCommand5 component. * @return the initialized component instance */ public Command getOkCommand5() { if (okCommand5 == null) {//GEN-END:|89-getter|0|89-preInit // write pre-init user code here okCommand5 = new Command("Ok", "OK", Command.OK, 0);//GEN-LINE:|89-getter|1|89-postInit // write post-init user code here }//GEN-BEGIN:|89-getter|2| return okCommand5; } //</editor-fold>//GEN-END:|89-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand2 ">//GEN-BEGIN:|92-getter|0|92-preInit /** * Returns an initiliazed instance of okCommand2 component. * @return the initialized component instance */ public Command getOkCommand2() { if (okCommand2 == null) {//GEN-END:|92-getter|0|92-preInit // write pre-init user code here

Page 45: DBMS Project

Appendix

37

okCommand2 = new Command("View Results", Command.OK, 0);//GEN-LINE:|92-getter|1|92-postInit // write post-init user code here }//GEN-BEGIN:|92-getter|2| return okCommand2; } //</editor-fold>//GEN-END:|92-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem2 ">//GEN-BEGIN:|94-getter|0|94-preInit /** * Returns an initiliazed instance of stringItem2 component. * @return the initialized component instance */ public StringItem getStringItem2() { if (stringItem2 == null) {//GEN-END:|94-getter|0|94-preInit // write pre-init user code here stringItem2 = new StringItem("Results", "0");//GEN-LINE:|94-getter|1|94-postInit // write post-init user code here }//GEN-BEGIN:|94-getter|2| return stringItem2; } //</editor-fold>//GEN-END:|94-getter|2| public void commandAction(Command c, Item item) { } /** * Returns a display instance. * @return the display instance. */ public Display getDisplay () { return Display.getDisplay(this); } /** * Exits MIDlet. */ public void exitMIDlet() { switchDisplayable (null, null); destroyApp(true); notifyDestroyed(); } /** * Called when MIDlet is started. * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet. */ public void startApp() { if (midletPaused) { resumeMIDlet (); } else { initialize (); startMIDlet (); }

Page 46: DBMS Project

Appendix

38

midletPaused = false; } /** * Called when MIDlet is paused. */ public void pauseApp() { midletPaused = true; } /** * Called to signal the MIDlet to terminate. * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released. */ public void destroyApp(boolean unconditional) { } public void getRs(String ss) { rs=ss; stringItem2.setText(rs); } } class DB extends Thread { String IP; int opt; String dt; int id; String rs=""; DBI dbi=null; public DB(String IP1,int opt1,String dt1,int id1,DBI dd) { IP=IP1; opt=opt1; dt=dt1; id=id1; dbi=dd; start(); } public void run() { try { //IP=textBox2.getString(); SocketConnection sc = (SocketConnection)Connector.open("socket://"+IP+":6776"); sc.setSocketOption(SocketConnection.LINGER, 5); InputStream is = sc.openInputStream(); OutputStream os = sc.openOutputStream(); DataInputStream in1=(new DataInputStream(is)); PrintStream out1=new PrintStream(os); os.write(opt); if(opt==0) out1.println(dt); else

Page 47: DBMS Project

Appendix

39

os.write(id); byte[] b=new byte[1]; while(in1.read(b)!=-1) rs+=(new String(b)); is.close(); os.close(); sc.close(); } catch(Exception e1) { rs="Error:"+e1.toString(); } dbi.getRs(rs); } } interface DBI { public void getRs(String ss); }