Basic Client-Server query

I'm in the early stages of writing a client-server program. I've got the client and the server communicating (I think). I send text from the client to the server. I then want the server side BufferedReader in to be read into a variable. I've tried doing it using String inputLine = in.readLine() but it keeps throwing an IOException. I can't work out why.
try {
            PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
         System.out.println("The printwriter and bufferedreader have been set up.");
            String inputLine, outputLine;
            inputLine = in.readLine();
            System.out.println(inputLine);
        } catch (IOException e) {
            System.out.println(e);
        }The serverSocket and socket have been set up properly as far as I can tell. It's just the above portion of code that seems to be causing a problem. My knowledge of Java is fairly basic at the moment, so any help would be greatly appreciated.

I agree that jdbc is probably the simplest approach here and it is probably the best introduction to java/database interaction. If you put some forethought into the design then it will also take some time out of transitioning to RMI should you decide to go that route. Is there a reason jdbc won't work for your application?
Oracle's JDBC download:
[http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html]
Oracle JDBC FAQ:
[http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm]
You can find lots of tutorials on connecting, querying, etc. via google as well.
RMI may help keep the client smaller and also gives some flexibility but if these (remote) methods are only going to be used for this application then once again jdbc may be the best choice. If there is a possibility that other applications may use them in the future then it might be a good choice.
[http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html]

Similar Messages

  • Help Needed With Basic Client/Server App

    I was wondering if anyone can help with a simple blackjack client/server application i've been writting (basically its a moddified chat application). The problem i'm having seems to lie within the connection management i've written.
    What i'm trying to get is that only 4 players can connect at one time and that each player takes a turn (which i've implemented using threads) to play their hand (as you would if you were playing it for real). The problem is that it will allow the players to connect, but oddly enough, it will not allow a new transaction to be created (i.e. allow a player to take their turn) until 2 players have connected.
    Even when it does create the transaction, after taking input from the client once, the server seems to stop doing anything without any error message of any kind.
    Its really annoyed me now, so you guys are my last hope!
    The code can be found in full here:
    Client Application: http://stuweb3.cmp.uea.ac.uk/~y0241725/WinEchoClient.java
    Server Application: http://stuweb3.cmp.uea.ac.uk/~y0241725/ThreadServer.java
    Card Class: http://stuweb3.cmp.uea.ac.uk/~y0241725/Card.java
    Deck Class: http://stuweb3.cmp.uea.ac.uk/~y0241725/Deck.java
    Please feel free to play around with this code as much as you feel necessary!

    (one last bump back up the forum before i give up on this completely)

  • Basic client Server stuff

    Say i have two classes class A and class B. class B is a server that is run on computer (comp1) and then i run class A a client on both Comp2 and Comp3. How do I ,
    Comunicate with the server (class B) on comp1?
    Share variables and other information between comp2 and comp3 by means of classB on comp1
    and how to I properly close the connection after these goals are accomplished.
    If someone could post a good tutorial covering these things or simply explain it themselves it would be greatly appreciated, Thanks for taking the time to look at this post.
    -Dizzixx

    Google is very good at answering these types of questions.
    http://www.google.com/search?q=java+client+server+tutorial

  • Client/Server hang up?

    I'm writing a basic client server program. I created an ArrayList to hold all the sockets of a connection so each client could, hopefully, eventually interact.
    Right now my client is a text field with a text area under it. A user types a command up top and then hits enter and sends that along to the server. However when i send in the message it seems to hang up and never sends back a reply. But what's really odd about it, is that if i close my server window and there by shutting it down the client then outputs exactly what i expected it to if it was working right. So im curious why there's this hangup in my code?
    Server:
    import java.awt.BorderLayout;
    import java.awt.Font;
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.util.ArrayList;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class Server extends JFrame{
              private JTextArea jta = new JTextArea();
              private static ArrayList<Socket> clients = new ArrayList<Socket>();
              public Server(){
                   getContentPane().setLayout(new BorderLayout());
                   getContentPane().add(new JScrollPane(jta), BorderLayout.CENTER);
                   jta.setFont( new Font( "Times", Font.BOLD, 20));
                   setSize(500, 300);
                   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   setVisible(true);
                   try{
                        setTitle("Server: " + InetAddress.getLocalHost().getHostName());
                        int clientNo = 1;
                        ServerSocket serverSocket = new ServerSocket(0);
                        jta.append("Port: " + serverSocket.getLocalPort() + "\n");
                        while(true){
                             Socket socket = serverSocket.accept();
                             InetAddress inetAddress = socket.getInetAddress();
                             clients.add(socket);
                             World thread = new World(socket);
                             jta.append("Connected with client :" + clientNo + "\n");
                             thread.start();
                             clientNo++;
                   }catch(IOException ex){
                        System.err.println(ex);
              public static void main(String[] args){
                   new Server();
              public static ArrayList getClients(){
                   return clients;
         }World:
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.util.ArrayList;
    import java.util.Scanner;
    public class World extends Thread {
         private Socket mySocket;
         private int myPort;
         private InetAddress myInetAddress;
         private String myHostName;
         private ArrayList<Socket> theClients;
         public World(Socket newSocket) {
              mySocket = newSocket;
              myPort = mySocket.getPort();
              myInetAddress = mySocket.getInetAddress();
              myHostName = myInetAddress.getHostName();
         public void run() {
              String test;
              Scanner input = null;
              PrintWriter output = null;
              try {
                   String fileName;
                   input = new Scanner(mySocket.getInputStream());
                   output = new PrintWriter(mySocket.getOutputStream(), true);
              }catch(IOException e){
              output.println("Please Enter Command");
              while((test = input.nextLine()) != null){
                   if(test.contains("get clients") ){
                        theClients = Server.getClients();
                        for(int i = 0; i < theClients.size(); i++){
                             output.println(theClients.get(i).getInetAddress().getHostName());
                        output.flush();
                   }else{
                        output.println("not sure");
                        output.flush();
    }Client:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.util.Scanner;
    import javax.swing.*;
    public class Client extends JFrame implements ActionListener{
         private JTextField jtf;
         private JTextArea jta = new JTextArea();
         private PrintWriter output;
         private Scanner input;
         public Client(String host, int port){
              JPanel p1 = new JPanel();
              p1.setLayout(new BorderLayout());
              p1.add(jtf = new JTextField(10), BorderLayout.CENTER);
              jtf.setHorizontalAlignment(JTextField.RIGHT);
              jtf.setFont(new Font("Times", Font.BOLD, 20));
              jta.setFont(new Font("Times", Font.BOLD, 20));
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(p1, BorderLayout.NORTH);
              getContentPane().add(new JScrollPane(jta), BorderLayout.CENTER);
              jtf.addActionListener(this);
              setSize(500,300);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
              try{
                   setTitle("Client: " + InetAddress.getLocalHost().getHostName());
                   Socket socket = new Socket(host, port);
                   input = new Scanner(socket.getInputStream());
                   output = new PrintWriter(socket.getOutputStream(), true);
                   jta.append(input.nextLine() + "\n");
              }catch(IOException ex){
                   jta.append(ex.toString() + "\n");
         public void actionPerformed(ActionEvent e){
              String nextLine;
              String findFile = jtf.getText().trim();
              ((JTextField)(e.getSource())).setEditable(false);
              if ( e.getSource() instanceof JTextField){
                        jta.append("Getting file: \"" + findFile + "\" \n");
                        output.println(findFile);
                        output.flush();
                        while(input.hasNext()){
                             nextLine = input.nextLine();
                             jta.append(nextLine + "\n");
         public static void main(String[] args){
              int portSend;
              if (args.length != 2){
                   System.out.println("not Enough arguments");
                   System.exit(-1);
              portSend = Integer.parseInt(args[1]);
              new Client(args[0], portSend);
    }

    Don't run networking code in the constructor. Start a separate thread for the accept loop.

  • Fault tolerance client /server

    hi
    i use a very basic client/server socket program
    very similar to sun:
    http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
    many client can connect to the server...
    i would like to add a fault tolerance...
    a client try to connect a few time... that don't work, the client try to the second server...
    does a need to do something similar to
    public class KKMultiServer {
        public static void main(String[] args) throws IOException {
            ServerSocket serverSocket1 = null;
            ServerSocket serverSocket1 = null;
            boolean listening = true;
            try {
                serverSocket = new ServerSocket(4444);
                serverSocket = new ServerSocket(4445);
            } catch (IOException e) {
                System.err.println("Could not listen on port.");
                System.exit(-1);
            while (listening){
             new KKMultiServerThread(serverSocket1.accept()).start();
                new KKMultiServerThread(serverSocket2.accept()).start();
            serverSocket1.close();
            serverSocket2.close();
    }thanks

    i need your help to finis my code
    what i want to do is to create to start 2 tread of server in my class main server....
    and each class server start a thread for each connection...
    each time a client do a request, i count it
    theses method is in server class
    import java.net.*;
    import java.io.*;
    public class ServerMain {
        public static void main(String[] args) throws IOException {
             //will call 2 time server here         
             Server server1 = new Server();
             Server server2 = new Server();
             server1(4444).start();
             server2(4445).start();
    import java.net.*;
    import java.io.*;
    public class Server extends Thread{
        private static int nbRequete=0;
        public synchronized int ajouterRequete(){
            return nbRequete++;
        public synchronized int getRequete(){
            return nbRequete;
        public int port=0;
        public Server(int port) {
            super("Server");
            this.port = port;
        public void run() {
            ServerSocket serverSocket = null;
            Socket s=null;
            boolean listening = true;
           // Server server = new Server();
           // int port;
            try {
                 //will put a port variable
                serverSocket = new ServerSocket(port);
                s=serverSocket.accept();
            } catch (IOException e) {
                System.err.println("Could not listen on port.");
                System.exit(-1);
            System.out.println("server run, wait connecting....");
            while (listening)
                new ServerThread(s).start();
            //serverSocket.close();
    import java.net.*;
    import java.io.*;
    public class ServerThread extends Thread {
        private Socket socket = null;
        public ServerThread(Socket socket) {
            super("ServerThread");
            this.socket = socket;
        public void run() {
            try {
                System.out.println("connexion successfull");
                System.out.println("Attente de l'entree.....");
                PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
                BufferedReader in = new BufferedReader(
                            new InputStreamReader(
                                socket.getInputStream()));
                String inputLine, outputLine;
                while ((inputLine = in.readLine()) != null) {
                    System.out.println("Server: " + inputLine);
                    inputLine = inputLine.toUpperCase();
                    out.println(inputLine);
                    if (inputLine.equals("Bye."))
                        break;
                out.close();
                in.close();
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
    }the server need to have different port
    i'm a little bit confuse
    i don't know how to finish this project
    :confused:
    i have some error i don't understand
    ServerMain.java:11: cannot find symbol
    symbol  : constructor Server()
    location: class Server
            Server server1 = new Server();
                             ^
    ServerMain.java:12: cannot find symbol
    symbol  : constructor Server()
    location: class Server
            Server server2 = new Server();
                             ^
    ServerMain.java:13: cannot find symbol
    symbol  : method server1(int)
    location: class ServerMain
            server1(4444).start();
            ^
    ServerMain.java:14: cannot find symbol
    symbol  : method server2(int)
    location: class ServerMain
            server2(4445).start();
            ^
    4 errors

  • Client server application using CORBA

    Hi
    I have a basic client server application running using CORBA/idl where the client starts up and the server says hello back to the client. I have figured out the basics but would like some help with these small problems.
    When I start the client, the server says hello. Thats OK. Now I want the client to start a simple java app (called c:\test.java - it works) that I created before. How?
    The next bit is when I close down the app "test" that I start, I want the server to realise that its closing and simply say goodbye on the client. How?
    If anybody can help me, I'd appreciate it.
    Thanks for your time,
    Shaun

    hi,
    to my knowledge, you will have to define a method in idl file and in your client, which server invocates(saying good bye etc) before shutting down..
    ls.

  • Client Server using Internet [ask]

    I have a client server project who connect between LAN connection and now I want to upgrade it into internet connection. I have search several programs who has similar architecture but none is suitable. Could anybody help me out how to build basic client server which connect using internet connection?
    I have attach my previous program below, I really appreciated if anyone may modify it so be able connect trough internet.
    Solved!
    Go to Solution.
    Attachments:
    Client.vi ‏262 KB
    Server.vi ‏164 KB

    Hi,
    with your program, you seem to have the full control over your house ;-). Why it shouldn't work over internet as it is? You have TCP open, TCP close...in Internet, you simply have to use other IP-adresses as the local ones. So can you specify your question? Or is it a problem with your LAN-infrastructure, that you have to configure your router to have access from outside?
    I don't see why it shouldn't work over Inet...
    christian
    THINK G!! ;-)
    Using LabView 2010 and 2011 on Mac and Win
    Programming in Microsoft Visual C++ (Win), XCode (Mac)

  • Capturing SQLNET client-server traffic

    Pardon the somewhat newbie-like question ...
    I am trying to build a API test stub where I need to be able to capture the requests and responses between third-party two-tier applications then replay the traffic. The replay is easy. The capture, though, is giving me trouble.
    For HTTP traffic, it is easy. I just change Internet Explore's HTTP port address to point to a fake proxy which records the requests the sends the requests onto the real web server.
    Is there an equivalent to this in the SQLNET world? I am hoping that a proxy already exists to do this.
    If not, is there a way to turn on a full trace for a specific client? I would need to capture all connections coming out of the client and no other client's connections.

    This could provoke quite a discussion.
    "If your client are on slow links you may, for example query 10,000 rows of data. "
    Generally, forms shouldn't be pulling back tens of thousands of rows from the database. Your user is unlikely to page through that much, so either you want a summary (which is best calculated on the database server and the summary results dragged across the network) or you are paging through records in the tens, not tens of thousands. (Look at the 'Number of recods buffered' property in your base table blocks. Bet it's one or two digits, not five!)
    "The information that is transmitted to the client is basically screen draw information - and this will be alot less than the 10,000 rows you were querying before. "
    As above. In client/server you shouldn't have been bringing stuff from the database down to the client that wasn't going to be on the screen anyway, especially if you had a slow network.
    Depending on how your application is written, it could well peform a lot worse on the web than in client server. Rather than having the client do a fair share of the work, it's now got to keep talking to the application server to get anything done.
    For example, because navigation triggers don't allow the use of restricted built-ins, rather than putting code in a 'post-text-item/when-validate-item' trigger on the relevant item, it gets put in a form level 'when-new-item-instance' trigger. It's a bit untidy in client/server but workable. Put it on the web, and every time the user tabs between fields, the form has to go off to the application server to fire the when-new-item-intance trigger to tell it what to do next.
    Another 'speed-bump' is if you have any synchronize bits (eg in a post-query trigger, or as part of a "I'm 10% complete" information messages in long running loops). These will also generate network traffic between the app server and form.
    While web server does have advantages, I wouldn't be selling it on it's performance improvements.

  • Client/Server network traffic.

    I don't know if here is the right forum to ask it, but let's go on.
    Nowadays we a system on Forms 4.5/windows/Oracle 8.0
    We have some clients machines linked to the server by a Frame-Relay link and we use Windows 2000 Terminal Server to reduce the network traffic.
    Well, we are gonna update to Forms 6i/Oracle 8i.
    I would like to know if Forms Server can be a good option to Windows 2000 Terminal Server.
    If I haven't been clear with my question I'll can do it again. I'm new on Forms 6i and I've just installed it to test (It hasn't been working yet....)
    Thanks in advance
    Ronaldo.

    This could provoke quite a discussion.
    "If your client are on slow links you may, for example query 10,000 rows of data. "
    Generally, forms shouldn't be pulling back tens of thousands of rows from the database. Your user is unlikely to page through that much, so either you want a summary (which is best calculated on the database server and the summary results dragged across the network) or you are paging through records in the tens, not tens of thousands. (Look at the 'Number of recods buffered' property in your base table blocks. Bet it's one or two digits, not five!)
    "The information that is transmitted to the client is basically screen draw information - and this will be alot less than the 10,000 rows you were querying before. "
    As above. In client/server you shouldn't have been bringing stuff from the database down to the client that wasn't going to be on the screen anyway, especially if you had a slow network.
    Depending on how your application is written, it could well peform a lot worse on the web than in client server. Rather than having the client do a fair share of the work, it's now got to keep talking to the application server to get anything done.
    For example, because navigation triggers don't allow the use of restricted built-ins, rather than putting code in a 'post-text-item/when-validate-item' trigger on the relevant item, it gets put in a form level 'when-new-item-instance' trigger. It's a bit untidy in client/server but workable. Put it on the web, and every time the user tabs between fields, the form has to go off to the application server to fire the when-new-item-intance trigger to tell it what to do next.
    Another 'speed-bump' is if you have any synchronize bits (eg in a post-query trigger, or as part of a "I'm 10% complete" information messages in long running loops). These will also generate network traffic between the app server and form.
    While web server does have advantages, I wouldn't be selling it on it's performance improvements.

  • Learning Client-Server Interaction

    Will I need to purchase the J2EE Sun One in order to learn about Client-Server interaction. I have been learning the J2SE , which has introduced me to many new and wonderful exciting possibilities in comparison to C++.
    Basically I am going to set up my own small server to practice with Java Servlets to test code that I will eventually learn to produce.
    Can anyone help please?
    I have no profit intentions, this is an independent learning chat query above. Thanks in advance.

    Hi ,
    You can download the free trial version of S1AS7 from
    http://wwws.sun.com/software/download/app_servers.html.
    It is j2ee 1.3 compatible .You can use it to test your servlets
    Hope this helps.Get back if you any issues
    -Amol

  • Client/server

    Hi, i am doing a client/server arc .I have a server , that will connected to the oracle , using jdbc.The client here is an application, how do i change it to applet?
    The server code
    import java.sql.*;
    import java.util.Properties;
    import java.io.*;
    import java.net.*;
    public class CommentsServer extends Thread {
    public static final int DEFAULT_PORT = 7777;
    protected int port;
    protected ServerSocket server;
    String username ="combtest";
    String password = "combtest";
    public static void main (String args[]) {
    int port=0;
    if (args.length == 1) {
    try {
    port = Integer.parseInt (args[0]);
    } catch (NumberFormatException e) { }
    try {
         Class.forName("oracle.jdbc.driver.OracleDriver");
    String sourceURL ="jdbc:oracle:thin:@klm:1521:KLMPMIS";
    String user="combtest";
    String password="combtest";
    catch (Exception e) {
    System.err.println("Failed to load JDBC driver.");
    System.exit (1);
    new CommentsServer (port);
    public CommentsServer (int port) {
    super ("Comments Server");
    if (port == 0)
    port = DEFAULT_PORT;
    this.port = port;
    try {
    server = new ServerSocket (port);
    } catch (IOException e) {
    System.err.println ("Error creating server");
    System.exit (1);
    start();
    public void run() {
    System.out.println ("Server Running");
    ThreadGroup connections = new ThreadGroup ("Comment Connections");
    connections.setMaxPriority(this.getPriority()-1);
    try {
    while (true) {
    Socket client = server.accept();
    System.out.println ("Connection from: " + client.getInetAddress().getHostName());
    CommentsConnection c = new CommentsConnection (connections, client);
    } catch (IOException e) {
    System.err.println ("Exception listening");
    System.exit (1);
    System.exit (0);
    class CommentsConnection extends Thread {
    static int counter = 0;
    protected ObjectInputStream in;
    protected PrintWriter out;
    public CommentsConnection (ThreadGroup group, Socket client) {
    super (group, "Connection " + counter++);
    try {
    in = new ObjectInputStream (client.getInputStream ());
    out = new PrintWriter (client.getOutputStream(), true);
    } catch (IOException e) {
    try {
    client.close();
    } catch (IOException e2) { }
    System.err.println ("Unable to connect.");
    return;
    start();
    public void run () {
    try {
    String mode = (String)in.readObject();
    if (mode.equals("insert")) {
         String name=(String)in.readObject();
    try {
         String u="jdbc:oracle:thin:@klm:1521:KLMPMIS";
         Connection con=DriverManager.getConnection(u,"combtest","combtest");
         PreparedStatement prep=con.prepareStatement("Insert into TEST values(?)");
         prep.setString(1,name);
         if(prep.executeUpdate()!=1)
         throw new Exception("Bad update");
    } catch (Exception e) {
    out.println ("Error updating: " + e);
    return;
    } else if (mode.equals("query")) {
    try {
         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@klmsph1:1521:KLMPMIS","combtest","combtest");
    Statement statement=con.createStatement();
    ResultSet result=statement.executeQuery("SELECT * FROM TEST");
    out.println("Name");
    int nameCol=result.findColumn("NAME");
    String name,user,comments;
    while(result.next())
         name=result.getString(nameCol);
         out.println(name);
    statement.close();
    con.close();
    } catch (Exception e) {
    out.println ("Error querying: " + e);
    return;
    } else {
    out.println ("Invalid Command: " + mode);
    } catch (Exception e) {
    out.println ("Error reading Stream: " + e);
    out.close();
    the client code
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CommentsClient extends JApplet{
    TextArea ta;
    TextField name;     
    public static final int DEFAULT_PORT = 7777;
    private static final String QueryString = "query";
    private static final String InsertString = "insert";
    private int port = 0;
    private String host = null;
    private OutputStream os = null;
    public CommentsClient (String host, int port, OutputStream os) {
    this.host = host;
    this.port = ((port == 0) ? DEFAULT_PORT : port);
    this.os = os;
    query();
    public CommentsClient (String host, int port, OutputStream os,
    String name) {
    this.host = host;
    this.port = ((port == 0) ? DEFAULT_PORT : port);
    this.os = os;
    insert(name);
    private void query () {
    PrintWriter out = new PrintWriter (os, true);
    try {
    Socket s = new Socket (host, port);
    ObjectOutputStream oos = new ObjectOutputStream (s.getOutputStream());
    // PrintWriter out=new PrintWriter(s.getOutputStream(),true);
    oos.writeObject (QueryString);
    oos.flush();
    BufferedReader in = new BufferedReader (new InputStreamReader (s.getInputStream()));
    String line;
    while ((line = in.readLine()) != null) {
    out.println (line);
    out.close();
    s.close();
    } catch (IOException e) {
    out.println ("Error querying." + e);
    return;
    private void insert (String name) {
    PrintWriter out = new PrintWriter (os, true);
    try {
    Socket s = new Socket (host, port);
    ObjectOutputStream oos = new ObjectOutputStream (s.getOutputStream());
    oos.writeObject (InsertString);
    oos.writeObject (name);
    oos.flush();
    BufferedReader in = new BufferedReader (new InputStreamReader (s.getInputStream()));
    String line;
    while ((line = in.readLine()) != null) {
    out.println (line);
    oos.close();
    s.close();
    } catch (IOException e) {
    out.println ("Error inserting." + e);
    return;
    public static void main (String args[]) {
    if (args.length == 0) {
    CommentsClient cc = new CommentsClient ("localhost", 0, System.out);
    } else if (args.length == 1) {
    CommentsClient cc = new CommentsClient ("localhost", 0, System.out, args[0]);
    the applet (acts as an interface)
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.io.*;
    //<applet code = "CommentsApplet" width = 800 height = 600>
    //</applet>
    public class CommentsApplet extends Applet {
    TextArea ta;
    TextField name;
    TextField user;
    TextField comments;
    public void init () {
    Panel p1 = new Panel(new BorderLayout(10, 10));
    Button b1 = new Button ("Query");
    p1.add (b1, BorderLayout.SOUTH);
    ta = new TextArea ();
    ta.setEditable(false);
    p1.add (ta, BorderLayout.CENTER);
    b1.addActionListener (new ActionListener() {
    public void actionPerformed (ActionEvent e) {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    CommentsClient cc = new CommentsClient ("localhost", 0, bao);
    ta.setText (bao.toString());
    add (p1);
    Panel p2 = new Panel (new BorderLayout (10, 10));
    Button b2 = new Button ("Insert");
    p2.add (b2, BorderLayout.SOUTH);
    Panel p3 = new Panel();
    name = new TextField ("", 10);
    p3.add (name);
    p2.add (p3, BorderLayout.CENTER);
    b2.addActionListener (new ActionListener() {
    public void actionPerformed (ActionEvent e) {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    CommentsClient cc = new CommentsClient ("localhost", 0, bao, name.getText());
    ta.setText (bao.toString());
    add (p2);
    the html file
    <html>
    <body>
    <hr>
    <applet
    code=CommentsApplet.class
    width = 400
    height = 400
    >
    </applet>
    <hr>
    </body>
    </html>
    Thanks in advance,
    Jessy

    hi
    I have no idea what you are doing. Strange programming
    public class CommentsClient extends JApplet why does it extends JApplet when it isn't a JApplet but an application
    and why is there a second applet
    public class CommentsApplet extends Applet (should this be extends JPanel??)
    but for normal classes this is the procedure
    rename the constructor in "public void init()" the method init is automaticly called by the browser.
    remove the main method if there is some code in the main method that needed move it to the init method. ( in your case the arguments can't be read from the command line but must be read out of the *.html file )

  • Urgent, Indication of new entry in database at forms 6i in client server

    I am working in client server environment using Oracle 9i + Developer 6i .I have an application in which different users send demands from different computers to his Boss for approval. At Boss computer a form is always open round the clock.
    Right now boss have time to time query the form at his computer, to check for any new demand for his approval.
    I only facilitate Boss with an indication in the status bar when new demand is send to him for the approval at his computer. I want just Like Yahoo Mail, when new mail is arrived there is always Icon at status bar to show arrival of new mail when we use Yahoo Messenger.
    Please send me solution of this problem on urgent basis.
    If somebody has an example, then please send me the FMB file.
    Best regards,
    Shahzad

    This is a duplicate post. If replying, please use Urgent, Indication of new entry in database at forms 6i in client server

  • Why timesten is slow in client/server mode

    i am testing Timesten client/server mode and find that
    it is to slow.
    when using dircet mode, timesten can precoss about 40000 query pre second
    but when change to client/ server mode
    it can only process 1500 query pre second.
    here is my config and test sql.
    [Test_tt702]
    Driver=//u01/oracle/TimesTen/tt70/lib/libtten.a
    DataStore=//u01/oracle/TimesTen/tt70/info/DemoDataStore/Test_tt702
    DatabaseCharacterSet=US7ASCII
    TempSize=64
    PermSize=250
    Temporary=1
    TypeMode=1
    CREATE TABLE TEST999
    A1 number NOT NULL PRIMARY KEY ,
    A2 number,
    A3 number
    network card is 1000m,
    query code:
    PreparedStatement pSel = dbConn.prepareStatement("select a1,a2 from TEST999 where a1=?");
    rs = null;
    int a1=0;
    int a2=0;
    for(int i=0;i<80000 ;i++)
         pSel.setInt(1,i );
    rs=pSel.executeQuery( );
    if (rs.next()) {
         a1 = rs.getInt(1);
         a2 = rs.getInt(2);
         if( i%8000==0) {
         System.out.println("select "+ i +" res="+a1 +" time " + getTime_v2());
         rs.close();
    direct mode time : 80000 query is 2 second
    client/server mode in the same machine : 80000 query is 12 second
    client/server mode in the different machine : 80000 query is 54 second
    any one have idea about this?
    is it the jdbc driver 's promble?

    it is to be expected that there will be a big difference in performance between direct mode and client/server due to much greater overhead in client/server, especially if the client is on a different machine. However, the differences you are seeing here are larger than I would normally expect.
    You say (I think) that the network is 1 GB, correct? What is the hardware spec of the test machine(s)? Have you tuned the O/S network stack for optimal performance?
    Typically, for local client/server using the fastest IPC mode (shmipc) I expect performance of around 20-30% of direct mode and for remote client/server with a GB LAN I would expect performance of around 10-20% of direct mode.
    Chris

  • Oracle form 6i in client server mode to call web service

    Hi,
    I am using oracle form 6i running in client server mode. My database version is 8.1.7.4. Now I am required to call an external web service. Is it possible to call web service without the existence of application server or web server? Please help!

    I have tried the method illustrated by the Form 10g Demo. However, when I select the Import Java Classes from the pull down menu, I have got the following error:
    PDE-UJI002 Unable to find the required Java Importer Classes.
    My Oracle Form version is as follows:
    Forms [32 Bit] Version 6.0.8.19.2 (Production)
    Oracle8i Enterprise Edition Release 8.1.7.0.0 - 64bit Production
    With the Partitioning option
    JServer Release 8.1.7.0.0 - 64bit Production
    Oracle Toolkit Version 6.0.8.19.1 (Production)
    PL/SQL Version 8.0.6.3.0 (Production)
    Oracle Procedure Builder V6.0.8.17.0 Build #863 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle Query Builder 6.0.7.1.0 - Production
    Oracle Virtual Graphics System Version 6.0.5.38.0 (Production)
    Oracle Tools GUI Utilities Version 6.0.8.11.0 (Production)
    Oracle Multimedia Version 6.0.8.18.1 (Production)
    Oracle Tools Integration Version 6.0.8.18.0 (Production)
    Oracle Tools Common Area Version 6.0.8.18.0
    Oracle CORE Version 4.0.6.0.0 - Production
    Please help !

  • Client/server socket based application

    hi does anyone have example of client/server socket based application using Spring and Maven
    where application do the following
    Client sends a request with a path to any file on the server
    „h Server reads the file and responds back with the content
    „h Client outputs the content to the console
    am trying to follow this
    http://www2.sys-con.com/itsg/virtualcd/java/archives/0205/dibella/index.html
    http://syntx.io/a-client-server-application-using-socket-programming-in-java/
    am using java 6

    i have attempt code but i wht to do the following
    client/server socket based application that will read the content of a file and stream the content of the file to the client. The client must simply output the content of the file to the console using System.out. The client must be able to run in a standalone mode (non-network mode) or in a remote mode.
    Additionally the client must be designed in a way that i can print the output to a console but must be interchangeable where if requirements change i can persist the response to file or persist the response to a database.
    /* Server.java*/
    ///ifgetBoolen= true then...
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.sql.*;
    public class Server
        static String array[][];
        // STEP 1 a1  
        // Server socket
        ServerSocket listener;
        // STEP 1 a2 Client connection
        Socket client;
        ObjectInputStream in;
        ObjectOutputStream out;
        public void createConnection() throws IOException
                System.out.println("\nSERVER >>> Waiting for connection.....");
                client = listener.accept();
                String IPAddress = "" + client.getInetAddress();
                DisplayMessage("SERVER >>> Connected to " + IPAddress.substring(1,IPAddress.length()));
          public void runServer()
            // Start listening for client connections
            // STEP 2
            try
                listener = new ServerSocket(12345, 10);
                createConnection();
                  // STEP 3
    //              processConnection();
            catch(IOException ioe)
                DisplayMessage("SERVER >>> Error trying to listen: " + ioe.getMessage());
        private void closeConnection()
            DisplayMessage("SERVER >>> Terminating connections");
            try
                if(out != null && in != null)
                      out.close();
                    in.close();
                    client.close();                
            catch(IOException ioe)
                DisplayMessage("SERVER >>> Closing connections");
        public static void define2DArray(ResultSet RS, int Size)
            try
                ResultSetMetaData RMSD = RS.getMetaData();
                DisplayMessage("SERVER >>> Requested arraySize: " + Size);
                if (RS.next())
                    array = new String[Size][RMSD.getColumnCount()];
                    for (int Row = 0; Row < Size; Row++)
                        for (int Col = 0; Col < RMSD.getColumnCount(); Col++)
                            array[Row][Col] = new String();
                            array[Row][Col] = RS.getString(Col+1);
                            DisplayMessage(array[Row][Col] + " ");
                        RS.next();
                else
                    array = new String[1][1];
                    array[0][0] = "#No Records";
            catch (Exception e)
                DisplayMessage("SERVER >>> Error in defining a 2DArray: " + e.getMessage());  
        public static void DisplayMessage(final String IncomingSMS)
            System.out.println(IncomingSMS);
    //client
    * @author
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class ClientSystem
        static Socket server;
        static ObjectOutputStream out;
        static ObjectInputStream in;
        static String Response[][];
        static boolean IsConnected = false;
        static int Num = 0;
        public static void connectToServer() throws IOException
            server = new Socket("127.0.0.1", 12345);
    //        server = new Socket("000.00.98.00", 12345);
            String IPAddress = "" + server.getInetAddress();
            DisplayMessage("\nCLIENT >>> Connected to " + IPAddress.substring(1,IPAddress.length()));
        public static void getStreams() throws IOException
            out = new ObjectOutputStream(server.getOutputStream());
            out.flush();
              in = new ObjectInputStream(server.getInputStream());
              IsConnected = true;
              DisplayMessage("CLIENT >>> Got I/O streams");  
        public static void runClient()
            try
                connectToServer();
                getStreams();
                  DisplayMessage("CLIENT >>> Connection successfull....\n");
                  DisplayMessage("CLIENT >>> Want to talk to server");
            catch (IOException ioe)
                System.out.print("."+Num);
                Num++;
        public static void closeConnection()
            try
                out.close();
                in.close();
                server.close();  
            catch(IOException error)
                DisplayMessage("CLIENT >>> Could not close connections");
        public static void Start()
            System.out.print("\nCLIENT >>> Attempting connection.....");
            try
                IsConnected = false;
                while (IsConnected == false)
                    runClient();
                    if (IsConnected == false)
                        Thread.sleep(100);
            catch (Exception e)
                DisplayMessage("CLIENT >>> Attempting connection.....");
        public static String sendSMS(String sms)
            Response = new String[0][0];
            try
                DisplayMessage("CLIENT >>> " + sms);
                out.writeObject(sms);
                out.flush();
                Response = (String[][])in.readObject();
                DisplayMessage("CLIENT >>> Waiting for server to respond...");
                for (int Row = 0; Row < Response.length; Row++)
                    System.out.printf( "_SERVER >>> \t");
                    for (int Col = 0; Col < Response[Row].length; Col++)
                        //DisplayMessage( "_SERVER >>> " + Response[Row][Col] + " ");
                        System.out.printf( "%s\t", Response[Row][Col]);
                    System.out.println();
                DisplayMessage("CLIENT >>> Query processed successfully....\n");
            catch(ClassNotFoundException cnfe)
                DisplayMessage("CLIENT >>> Class not found for casting received object");
            catch(IOException ioe)
                reConnect();          
            catch (Exception sqle)
                DisplayMessage("CLIENT >>> Error sending query ??? " + sqle.getMessage());
            return "transmission successfull";
        public static void reConnect()
            try
                DisplayMessage("CLIENT >>> Connection was lost. Trying to reconnect...");
                closeConnection();
                Thread.sleep(100);
                IsConnected = false;
                while (IsConnected == false)
                    runClient();
                    Thread.sleep(200);
            catch (Exception e)
                DisplayMessage("CLIENT >>> Error trying to Re-Connect...");
        public static void DisplayMessage(final String IncomingSms)
            System.out.println(IncomingSms);
        System.out.printf("Isms: %s", IncomingSms);  ///naah.
        public static String[][] getResponse()
            return Response;
        public static String getResponse(int row, int col)
            return Response[row][col];
    how can i do below using above code
    The program must be able to work in a non-networked mode. In this mode, the server and client must run in the same VM and must perform no networking, must not use loopback networking i.e: no “localhost” or “127.0.0.1”, and must not involve the serialization of any objects when communicating between the client and server components.
    The operating mode is selected using the single command line argument that is permitted.
    imust use a socket connection and define a protocol. networking must be entirely bypassed in the non-network mode.

Maybe you are looking for

  • Resetting a password is there a way?

    A friend of mine lost all his original disks for his Macbook. My question is: Is there a way to rest his login password in single user mode without causing more harm or anyway other way of reseting the password without the disks. He is not worried ab

  • Help in creat view

    i have a accounting table consist of the folwing fields: ACC_ID NOT NULL NUMBER(10) ACC_DESC VARCHAR2(100) ACC_PARENT_ID NUMBER(6) IS_PARENT NUMBER(1) and another table for transacion have two filds: ACC_ID NUMBER(10) AMOUNT NUMBER(20,2) THE ACCOUNT

  • Email Sending Fail

     I have a problem of sending mail through my NOKIA device 5235 for 30 days,I already complaints by mails & calls more than 10 times for this problem to customer care but not given solution for this matter.when I tried to  send the mail below errors i

  • How to set fixed value to Column

    Hi Experts, I create a matrix in that matrix qty and %columns is there. Here first row % column is must and should 100.if user try to change then message will be get and % value chaged to 100 again how is it possible,only 1st row % column only.2nd an

  • Had to replace my hard drive and now I can't update iPhoto.

    (Originally posted this question in the MacBook Pro community but it might do better here.) When I try to through the App Store I get this message: To update this application, sign in to the account you used to purchase it. I submitted this to the Ap