Link to home
Start Free TrialLog in
Avatar of sara_uk
sara_uk

asked on

database in server?important please

can any expert help me on this stage,because iam new in java world,iam using java application to build up my server program and iam stuck on how to store data in hashtable class,i will attach my server console coding..
if you please run this program and let me know what is missing...
after this stage what suppose i do,
i would like to know step by step?

thankyou and appreciated your assistant.
NOTE: iam not using java swing..



         // Importing java libraries.
import java.awt.*;
import java.awt.event.*;

          // Extending the application frame and implementing ActionListener to preform actions
public class youServer extends Frame implements ActionListener{


          // Definig variables
    private TextField TF1,TF2,TF3,TF4,TF5;
    private Button    B1;
            Label     L1, L2, L3, L4, L5, L6;
            Font      F1, F2, F3, F4, F5, F6;
            Panel     P1, P2, P3, P4, P5, P6;
    public youServer() {


          // Giving a label to the frame
        super("---------------------------------------------------------A Book Shop Storing System-------------------------------------------------------");

          // Building the server GUI which consist of 5 TextFields and a Button
          // Setting the overall layout of a frame with 7 panels
          setLayout(new GridLayout(7,1));
          P1 = new Panel();
          add(P1);
          P2 = new Panel();
          add(P2);
          P3 = new Panel();
          add(P3);
          P4 = new Panel();
          add(P4);
          P5 = new Panel();
          add(P5);
          P6 = new Panel();
          add(P6);

          // Setting the layout of panel 1 with one Label
          P1.setLayout(new FlowLayout(FlowLayout.LEFT));
          L1= new Label("Enter The Book Details To The Database And Then Press Update:");
          L1.setForeground(Color.blue);
          F1 = new Font("Helvitica",Font.BOLD,20);
          L1.setFont(F1);
          P1.add(L1);


          // Setting the layout of panel 2 with one Label and a TextField
          P2.setLayout(new FlowLayout(FlowLayout.LEFT));
          L2  = new Label("Title:      ");
          L2.setForeground(Color.orange);
          TF1 = new TextField(14);
          F2 = new Font("Helvitica",Font.BOLD,15);
          L2.setFont(F2);
          P2.add(L2);
          P2.add(TF1);



          // Setting the layout of panel 3 with one Label and a TextField
          P3.setLayout(new FlowLayout(FlowLayout.LEFT));
          L3  = new Label("ISBN:     ");
          L3.setForeground(Color.orange);
          TF2 = new TextField(14);
          F3 = new Font("Helvitica",Font.BOLD,15);
          L3.setFont(F3);
          P3.add(L3);
          P3.add(TF2);

          // Setting the layout of panel 4 with one Label and a TextField
          P4.setLayout(new FlowLayout(FlowLayout.LEFT));
          L4  = new Label("Author:   ");
          L4.setForeground(Color.orange);
          TF3 = new TextField(14);
          F4 = new Font("Helvitica",Font.BOLD,15);
          L4.setFont(F4);
          P4.add(L4);
          P4.add(TF3);

          // Setting the layout of panel 5 with one Label and a TextField
          P5.setLayout(new FlowLayout(FlowLayout.LEFT));
          L5  = new Label("Quantity: ");
          L5.setForeground(Color.orange);
          TF4 = new TextField(14);
          F5 = new Font("Helvitica",Font.BOLD,15);
          L5.setFont(F5);
          P5.add(L5);
          P5.add(TF4);

          // Setting the layout of panel 6 with one Label, a TextField and a Button
          P6.setLayout(new FlowLayout(FlowLayout.LEFT));
          L6  = new Label("Price £:   ");
          L6.setForeground(Color.orange);
          TF5 = new TextField(14);
          F6 = new Font("Helvitica",Font.BOLD,15);
          L6.setFont(F6);
          P6.add(L6);
          P6.add(TF5);
          B1 = new Button("Update");
          // Adding ActoinListener to Button B1
          B1.addActionListener(this);
          P6.add(B1);

          //seting the size of the frame
          setSize(new Dimension(600, 500));

          // show the GUI
          show();                 // Visible the frame as TRUE
      }
public static void main(String[] args) {
           // use the constructor to build the GUI,creating an object called server
           youServer server = new youServer();

      }


public void actionPerformed(ActionEvent e) {

      }
      }
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sara_uk
sara_uk

ASKER

i know that step will close my window,but i didn't meant that..i wish to know how to store the data in database using hashtable class?

any answer i appreciated
Not quite sure what you're getting at. A hashtable is a way of storing things in memory and is not persistent. A database implements persistence.
Avatar of sara_uk

ASKER

okay then,how do i create a class for hashtable in server program and what will include?because in my program i wish to store the book,isbn and author..when i press the button it will get the values of that key,like quantity and price....

now i wish to know what is the next step in my program?i other word,what suppose i do now?

thanks alot
Avatar of sara_uk

ASKER

okay then,how do i create a class for hashtable in server program and what will include?because in my program i wish to store the book,isbn and author..when i press the button it will get the values of that key,like quantity and price....

now i wish to know what is the next step in my program?i other word,what suppose i do now?

thanks alot
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sara_uk

ASKER

hi again..
first of all,iam very much thanks to you.further more,you didn't mentioned which library i will choose for that ,finally,do i need to put or implement these codes in my server program..


iam really much appreciated for assistant..
Avatar of sara_uk

ASKER

hi again..
first of all,iam very much thanks to you.further more,you didn't mentioned which library i will choose for that ,finally,do i need to put or implement these codes in my server program..


iam really much appreciated for assistant..
First of all, before you do *anything* else, you should have a Book class. Then you should decide what to do next. What do you mean by 'store'? In memory? In the file system?

NetWize - the hashCode of the Book's isbn (after having been stripped of non-alpha-numeric symbols) should be sufficient for a Book's key.
Avatar of sara_uk

ASKER

iam sorry guys...i didn't understand anything from your comments,i mean where i need to put those codes and to implement them in server program...if u didn't understand yet then tell me what i will do next?

thanks alot and appreciated..

Don't worry too much about comments getting passed around between experts. You understand this i hope?:

>>First of all, before you do *anything* else, you should have a Book class.
Avatar of sara_uk

ASKER

ok then...how do i create that book class with codes and where to locate it?if you help me please and provide me with example,i appreciate that..

thanks
sara
You need to study basic OOP with Java. Try http://sepwww.stanford.edu/sep/josman/oop/oop1.htm
Avatar of sara_uk

ASKER

hi dear NetWize:
in the above example you written isbn=string,in this case it's int.

if you please rephrase those codes and write them in proper way that will help me to add them in java for testing purpose?

i appreciate your answer..
thanks
replace public String isbn;
with

public int isbn

// and change the hashCode-method to

public int hashCode() {
  return isbn;
}
isbns can contain character data as well as digits AFAIK.
Yes, CEHJ, that's right. But if sara_uk's isbn is int...
Avatar of sara_uk

ASKER

thanks alot experts...

finally,if you please submit my example above plus yours and conclude it for me,i mean can you relate all what i did above with your code and give me the final codes..
i hope you understand what i mean..

iam very much thanks to experts like you dear...

thanks alot
 
Over to you NetWize - i don't do homework for people - only assist ;-)
Well sara_uk,
I think you're asking too much. This is not about coding someone elses programs but helping you do it yourself. If we'd write your code what benefit would you have? Next time you won't be able to do it yourself again.

You really should invest some time in learning the language.

Sorry I can't help you.

Jan
I suggest that if you don't know how to write a Book class you follow the link i posted. You won't get people to write your homework here.
sara_uk:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.