Urgent :problem with JTable on server program

hi all i am writing an internet cafe timer.there is a table with the following colums:PC Name,IP Address,Status,Time Left, Time Login. ,on the server GUI. Whenever a client connects,a new row having the clients details is added to the table model, which reflects on the table.but if a client disconnects and reconnects, i want it to search thru the rows in the model, if there is a row with its information already,it shouls simply update the status column to "Reconnected", and not add an entirly new row, but if there is no row with its information, it can then add a new row with its information.
Simply put, when a client connects,it should check
1)if the table is empty, add a new row;
2)else, check if tabe already has a row for the client, then update the row,else add a new row.
its not working this way.it only works for the first client to connect,if other clients connect and disconnect,it still adds a new row, instaed of updating.
the method doTable() in class ClientThread is what i use .please check it out and help me.
i have a thread for each client.when a client connects, the server starts the thread and passes an instance of the server ui to the thread, so the threads acess the tablemodel thru this instance.
Here is a simple run down of my classes
CafeServer.java
* @(#)CafeServer.java
* @author obinna
* @version 1.00 2007/3/10
import java.net.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.sql.*;
public class CafeServer {
     int serverPort;
     int serverLimit;
     //ServerSocket serversocket;
     private static int rownum = -1;
     private static Connection conn;
     private static CafeServerUI serverUI;
* Creates a new instance of <code>CafeServer</code>.
public CafeServer() {
     try{
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          conn = DriverManager.getConnection("jdbc:odbc:cafetimer","","");
          System.out.println("connection established with cafetimer database");
     }catch(Exception ex){
          JOptionPane.showMessageDialog(null,"Cannot find database");
          serverUI = new CafeServerUI( this,conn );
public void closeServer(){
     System.exit(0);
public static void main(String[] args) throws IOException{
// TODO code application logic here
try{
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     new CafeServer();
catch(Exception ex){
     JOptionPane.showMessageDialog(null,"Could Not Find System Look and Feel.\nDefault L&F Loaded.");
     JFrame.setDefaultLookAndFeelDecorated(true);
ServerSocket serverSocket = null;
boolean listening = true;
try {
serverSocket = new ServerSocket(4444);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(-1);
while (listening)
     new ClientThread(serverSocket.accept(),serverUI,conn).start();
serverSocket.close();
CafeServerUI.java
//import statements.......................................
public class CafeServerUI extends JFrame{
     public Vector pins = new Vector<String>();
     public DefaultTableModel model;
     public JTable table;
     protected JTextArea msgarea;
     protected JScrollPane scrpane;
     protected JPanel mainp,northp,leftp,rightupp,rightp;
     protected String[] colnames = {"Computer Name","IP Ad
.............................................................constrctor follows
ClientThread.java
import java.io.*;
import java.net.*;
import java.sql.*;
public class ClientThread extends Thread{
     private Socket socket = null;
     private String pin, timeleft, pin3,timeleft3,tleft;
     private CafeServerUI csui = null;
     private Ticket ticket;
     private RemainingTime remtime;
     private String hostname,ipadd;
     private int rownum;
     private Connection conn;
     private Statement stmt;
     private ResultSet rs;
     private boolean found;
     public ObjectOutputStream outputStream;
     public ObjectInputStream inputStream;
     private Admin admin;
     boolean found2 = false;
     //private String[] newrow = new String[5];
public ClientThread(Socket socket,CafeServerUI csui,Connection conn) {
          super("Client Thread");
          this.socket = socket;
          this.csui = csui;
          this.conn = conn;
          try{
               stmt = this.conn.createStatement();
          }catch(Exception ex){
               System.out.println(ex.getMessage() + " : " + ex);
          //this.rownum = rownum;
          hostname = this.socket.getInetAddress().getHostName();
          ipadd = this.socket.getInetAddress().getHostAddress();
          //sString[] newrow = {hostname,ipadd,"Connected","",""};
          doTable();
          //System.out.print("table row " + this.rownum);
          this.csui.oos.addElement(ClientThread.this);
public void doTable(){
     String[] newrow = {hostname,ipadd,"Connected","",""};
     if(this.csui.model.getRowCount() == 0){
               this.csui.model.addRow(newrow);
          }else{
               for(int i=0; i < this.csui.model.getRowCount(); i++ ){
                    String hname = (String)this.csui.model.getValueAt(i,0);
                    if(hname.equalsIgnoreCase(hostname)){
                         this.csui.model.setValueAt("Re Connected",i,2);
                         break;
                    }else{
                         this.csui.model.addRow(newrow);
                         break;
.....public void run()....

In the UI is defined the InputMap/ActionMap pair to respond to keys. There is defined an action for ENTER. I have had the same problem, and the only thing that worked for me was to clear the actionMap, and reassign some keys to their original action, and some (e.g. ENTER, TAB) to my actions. This worked. With TAB is harder beacuse i guess it's deeper in the JVM implemented, but after a while i've managed to overwrite that too.

Similar Messages

  • Problems with my client server program

    I am programming a client to server messeging system. I have been getting this error. [i programed a JOptionPane window if an IO error ocured and every time i connect with the client in keeps popping up.  Here is part of my code from the [b]server:
         class listener extends Thread {
              public void run() {
                   try {
                        recever = new ServerSocket(port);
                        send = recever.accept();
                        Thread process = new Thread(new mt());
                        process.start();
                   catch (IOException ioe) {
         class mt extends Thread {
              public void run() {
                   try {
                        send.setSoTimeout(1);
                   catch (IOException ioe) {
                   while (true) {
                        try {
                             in = new BufferedReader(new InputStreamReader(send.getInputStream()));
                             data.add(in.readLine());
                             JOptionPane.showMessageDialog(null, data, "this was the data", JOptionPane.INFORMATION_MESSAGE);
                        catch (NullPointerException ioe) {
                        catch (IOException ioe) {
                             JOptionPane.showMessageDialog(null, "Error in the server!!", "ERROR", JOptionPane.WARNING_MESSAGE);
         public static void main(String args[]) {
              new server().setVisible(true);
    }Now froim the client:
    if (e.getSource() == go) {
                   if (connected == true) {
                        try {
                             out = new PrintWriter(new OutputStreamWriter(connector.getOutputStream()));
                        catch (IOException ioe) {
                             JOptionPane.showMessageDialog(null, "Error sending", "ERROR", JOptionPane.WARNING_MESSAGE);
                        type.setText("");
                   if (connected == false) {
                        JOptionPane.showMessageDialog(null, "You are nnot connected!!", "ERROR", JOptionPane.WARNING_MESSAGE);
    If you need more code to understand my problem just ask.
    Thanx

    Don't you think it might be a good idea to find out what kind of IOException you're getting? At least display ioe.getMessage. showMessages will take an Object array instead of a single string so you can do:
    JOptionPane.showMessageDialog(null, new Object[]{"Error in server", ioe.getMessage}, "Error",
    JOptionPane.ERROR_MESSAGE);

  • (URGENT) problem with JTable: can't catch ENTER and control focus in JTable

    I hava a JTable and a AbstractTableModel.
    Here is what i want to DO.
    When I press the ENTER or TAB I want to set focus to cell wich is 2 position away from the the sell I am editing
    on the same row in the JTable. How can I do this.
    in fact, that is my real question HOW to ?
    When I press the ENTER or TAB in JTABLE I want to tell to JTable which cell to grab the focus

    In the UI is defined the InputMap/ActionMap pair to respond to keys. There is defined an action for ENTER. I have had the same problem, and the only thing that worked for me was to clear the actionMap, and reassign some keys to their original action, and some (e.g. ENTER, TAB) to my actions. This worked. With TAB is harder beacuse i guess it's deeper in the JVM implemented, but after a while i've managed to overwrite that too.

  • URGENT Problem with Greek Character from an Oracle database

    Hello, I am having a serious and urgent problem with the character settings of an oracle database (8.1.7). The database is sitting in a solaris unix server and when we run the env command we have the following in the NLS_LANG parameter: AMERICAN_AMERICA.WE8ISO8859P1 (I do not know if this is helpful). When I retrieve data from oracle database (through a VB.NET 2005 program)to a dataset I use a special font in order to see the greek characters (HELLASARIAL). But when I am trying to save these data to a TXT file the greek characters are like Chinese to us. I tried several encodings (System.Text.Encoding.GetEncoding(869)) but without success. Can someone tell me how to convert the oracle greek characters during the selection or during the saving to the TXT file?
    Please respond as fast as you can.
    Thanks in advance

    Here is the answer of the microsoft:
    I have the information that you have a VB.Net 2005 application connected to an Oracle database 8.1.7.4 hosted on a UNIX server.
    This database has the CharacterSet WE8ISO8859P1.
    When retrieving Greek characters from this database in the application, you cannot see them.
    Could you please send me a screenshot of these characters in the .Net application?
    Are they displayed as gibberish, or as inverted questions marks (?)?
    I already had similar cases with Hebrew characters hosted on an Oracle database.
    These characters were displayed as questions marks on the client side.
    This is due to the fact that System.Data.OracleClient is using the Server CharacterSet to display the characters.
    If your Greek characters are not stored in the WE8ISO8859P1 characterset, then they won’t display correctly on the client-side.
    This is different from OLEDB where you could interact on client side by modifying the NLS_LANG parameter in the registry HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0.
    The client NLS_LANG and the server CharacterSet had to match in order to correctly display the data, and avoid SQL*NET conversion.
    So there are two solutions to your case:
    - The first one is to create a new database using the P8 characterset. The Oracle .Net managed provider will so be able to use it and display the characters correctly.
    - The second one is to use the OLEDB.Net managed provider, and then use OLEDB for Oracle provider. OLEDB will take care of the client NLS_LANG registry parameter.
    Would it be possible to test your application against an Oracle database with WE8ISO8859P8 characterset?
    Would it be possible to test it with the OLEDB .Net managed provider, and after checking the NLS_LANG client registry parameter?

  • Problem with sun app server startup

    hi,
    i am getting problem with sun app server default start.the error is::
    [#|2006-03-01T13:54:35.121+0530|WARNING|sun-appserver-pe8.2|javax.enterprise.tools.launcher|_ThreadID=10;|LAUNCHER005:Spaces in your PATH have been detected. The PATH must be consistently formated (e.g. C:\Program Files\Java\jdk1.5.0\bin; ) or the Appserver may not be able to start and/or stop.  Mixed quoted spaces in your PATH can cause problems, so the launcher will remove all double quotes before invoking the process. The most reliable solution would be to remove all spaces from your path before starting the Appservers components.  |#]
    now i am useing Win Xp operating system,
    show me a solution.
    Regs..
    Narasimha

    You haven;t specified the exceptions you r getting ........while starting your default server.
    if u r getting exception about InetClass then connect your system with LAN/Internet then your problem will be solved becoz i m using same location address as you specified, space doesn't matter at all - i think so, it is running fine........

  • Problems with AOL IMAP server connection on my BlackBerry Z10 STL100-3, and BB PlayBook 64GB WiFi

    Problems with AOL IMAP server connection on my BlackBerry Z10 STL100-3, and BB PlayBook 64GB WiFi
    Thursday 4:20am EST, 02-19-2015
    Hi, My connection to the AOL IMAP server has suddenly failed - Says "Not Connected" on Accounts page
    I haven't changed anything and this just started failing this morning.
    I've saw same issue on my Blackberry PlayBook 64GB.
    Is anyone else recently experiencing AOL IMAP Errors?
    Solved!
    Go to Solution.

    Yes! Same thing happened suddenly to my Z10 this morning. No AOL. 

  • HT4864 I am getting a triangle with an exclamation point next to my inbox...it says: There may be a problem with the mail server or network. Verify the settings for account "MobileMe" or try again.  The server returned the error: Mail was unable to log in

    I can send but cannot recieve email
    This is the messege I am gewtting:
    There may be a problem with the mail server or network. Verify the settings for account “MobileMe” or try again.
    The server returned the error: Mail was unable to log in to the IMAP server “p02-imap.mail.me.com” using “Password” authentication. Verify that your account settings are correct.
    The server returned the error: Service temporarily unavailable

    Also if I go to system preferences accounts and re-enter the password it fixes the glitch sometimes.

  • Problem with the new server UCS C220 for set IP to CIMC

    Hi
    We’ve a problem with the new server UCS C220.
    We bought two servers UCS C220 M3 for CallManager 8.6 with High Availability.
    When we turn on the server during the boot and when it tells us, oppress F8 to enter at the CIMC and set the IP. But it never enters at the CIMC.
    Then, we configure our DHCP server and our switch, we connect the three gigabyte ports to our switch to give him an IP to the CIMC, so and then can enter via browser, but neither works.
    Note. The dedicated management NIC does not link, the other two ports do make link.
    What do you suggest to put an IP to CIMC and start installing our applications?
    regards

    You may have noticed that there is no DVD rom on the c220. What you need to do is:
    Login into the CIMC from your browser
    Luanch the KVM
    Insert the VMware DVD in your machines drive
    On the KVM pop up there should be a tab to mount the drive, after mounting it click on Macros and choose ctrl_alt+delete to restart.
    After the VMware OS installs press F2 to enter IP.
    Browse to the VMware ip to download the Vsphere client
    Open the Vsphere client, enter the ip of the vmware and the username will be root and no password if you did not set one.
    You can now upload OVA templates or manually create virtua machine from this enviroment.
    Hope this help

  • Why do I get an "unable to connect - There may be a problem with the mail server or network." message from iCloud.  I have verified the settings.  I can access my iCloud account online but can't send or receive e-mail via the mail account.

    Text limits to the "Question" link prevents a full explanation:
    This is a long-time problem.  I have tried to resolve it with Apple but their "Customer Support" is merely a name.
    I can go online and access my e-mail but when I try to send or receive e-mail via iCloud through my internet server (Google fiber now but the same situation existed with my prior service), I receive "There may be a problem with the mail server or network.  Verify the settings for 'Apple Email' and try again.
    "The server returned the error:  The server 'p0-imap.mail.me.com' refused to allow a connection on port 143."
    Well, I have verified the setting and tried again and again and …
    Well, you get the idea …

    JungleTaxi Cabbie wrote:
    Csound1: iCloud: Configuring Mail with Mac OS X v10.6 or iOS 4
    Enter your Incoming Mail Server, User Name, and Password using the following settings:
    Incoming Mail Server: mail.me.com
    User Name: Your iCloud email address (excluding @me.com)
    Password: Your password
    Last Modified: Jun 27, 2013
    Maybe you should test these things before calling people out, because these settings do function perfectly well.
    iCloud is not supported on Snow Leopard or lower, why bother to mention it?
    The OP has an iCloud account, and that can not be opened without Lion or Mountain Lion (on a Mac), IOS5 or 6 (on an iPhone/iPad)
    The document I linked to is Apples documentation for iCloud on current devices,I don't care whether you believe that you know better than they do, but it will affect the people who follow your advice as it won't work
    JungleTaxi Cabbie wrote:
    Also, if you're not running Lion or Mountain Lion, there is no "Mail, Contacts & Calendars" prefpane.
    I never said that there was, perhaps you imagined it.

  • Selection Problem with JTable

    Hello,
    i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
    I preffered the style from MS Outlook Express where you can select the email accounts to edit.
    It is a table like this:
    Account name  |   Type  |   ...
    --------------|---------|---------------------
    Hotmail       |   POP3  |
    GMX           |   IMAP  |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
    Please help me!
    Thanks.
    Warlock

    Maybe this will helpimport java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        String[] head = {"One", "Two"};
        String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
        JTable jt = new JTable(data, head);
        jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.setCellSelectionEnabled(true);
        jt.setRowSelectionAllowed(false);
        jt.setColumnSelectionAllowed(false);
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    class MyTableSelectionModel extends DefaultListSelectionModel {
      public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(0, 0);
    }

  • Intermittent proxy error "There is a problem with the proxy server's security certificate. Outlook is unable to connect to the proxy server "

    Hi all,
    From time to time (at least once a day), the following message pops up on the user's screen:
    "There is a problem with the proxy server's security certificate. Outlook is unable to connect to the proxy server . Error Code 80000000)."
    If we click "OK" it goes away and everything continues to work although sometimes Outlook disconnects. It is quite annoying...
    Any ideas?
    Thank you in advance

    Hi,
    For the security alert issue, I'd like to recommend you check the name in the alert windows, and confirm if the name is in your certificate.
    Additionally, to narrow down the cause, when the Outlook client cannot connect again, I recommand you firstly check the connectivity by using Test E-mail AutoConfiguration. For more information, you can refe to the following article:
    http://social.technet.microsoft.com/Forums/en-US/54bc6b17-9b60-46a4-9dad-584836d15a02/troubleshooting-and-introduction-for-exchange-20072010-autodiscover-details-about-test-email?forum=exchangesvrgeneral
    Thanks,
    Angela Shi
    TechNet Community Support

  • There is a problem with the proxy server's security certificate. The name on the security certificate is invalid or does not match the name of the target site "Mailserver"

    Good day Guys
    First of all I am not an Exchange Expert, and I might be asking a very stupid question, but please bare with me. :) 
    While I was on leave our Mail server fell over and The company got a Specialist to help out for the time being.
    We where\are on Microsoft Exchange 2007 , which Fell over, and the specialist was able to recover as much data as he could.
    They then installed Exchange 2013 and tried to migrate everything from 2007 to 2013 and not everything migrated over.
    But the problem is, Outlook Anywhere was enable on 2007 and worked a 100% (before the disaster)
    With Exchange 2013 I get the following error message when trying to connect With Outlook 2013, using an external connection:
    "There is a problem with the proxy server's security certificate. The name on the security certificate is invalid or does not match the name of the target site "Mailserver"
    Outlook is unable to connect to the Proxy server. (Error Code 0)"
    Has anyone had the Similar when migrating over from 2007 to 2013 or is this an Issue on IIS and nothing to do with Exchange migration?
    Your assistance will be greatly appreciated.

    Hi,
    Firstly, I would suggest we use Exchange 2013 FE as the Outlook Anywhere proxy server.
    For the certificate issue, it mostly occurs because the host name that Outlook are trying to access does not match the certificate SAN. Please check with this point. If they do not match, you
    can change the host name by referring to the following article:
    https://support.microsoft.com/kb/940726/en-us?wa=wsignin1.0
    Thanks,
    Simon Wu
    TechNet Community Support

  • Logon problem with oracle management server

    I have problem with Oracle Management Server when I connect to the OMS message comes
    The exception (java.lang.NullPointerException) occurred.
    if any body have any idea pls tell us

    Hi,
    Oracle has changed the Enterprise Manager from version 1.5 to 2.0 .
    With the new Oracle8i dataase server another service has been added.
    If you want to user the OEM you have to install The Managment Server.
    The Managment server has its own user and privileges and is recommended when using OEM.

  • Backup Problem with only Production Server

    Hi all
    Here i have backup problem in only production server. In my tape drive device all schedule backup of Development  server and Quality Server and Production server . In this i get all backup in Development and Quality server, But in Production server backup was fail and not only one all backup is fail from last 2 days . So can u tell me what is the problem with my production server and how can i find it in production.
    And any hardware issue or OS issue is responsible for this.
    Please help me out.
    Thanks
    Keyur

    Hi,
    Can u pls post us the backup log? Also let us know ur product details like OS, SAP, DB version and also the backup tool(if any).
    Regards,
    Varadharajan M

  • I have problem with Adobe ColdFusion Server Manager.

    I have a problem with Adobe ColdFusion Server Manager when you log on and connect to the server. An advantage of the settings do not load.

    When I see others screen cuts of CF Server Manager here:
    http://www.coldfusionjedi.com/index.cfm/2009/10/21/Quick-example-of-Diff-within-the-ColdFu sion-Server-Manager
    http://forta.com/blog/index.cfm/2009/7/6/Simplified-ColdFusion-Server-Management
    the Errors View button display’s the yellow ! sign. Without a better guide I just thought that is a normal button icon until I noticed Charlie comment earlier in the thread and I thought hold up that is not normal.
    As it is when I press Errors View I get “no error” which might be because there is none or just simply not giving meaningful details as per some other CF Server Manager limitations previously noticed in other threads on forum here.
    I just hope some of that helps the original post to do with the display of the settings on left side. Maybe a better look at the error might help? Does anything get logged in CFadmin UI > Debugging & Logging > Log Files that relates to issue?
    Regards, Carl.

Maybe you are looking for

  • HELP-iPOD NOT RECOGNIZED BY WINDOWS!!! UNIQUE ISSUE HERE!!

    I have a 4GB silver mini. The following things happened: I have a new laptop. This is the first time I plugged in an iPod in it. For this case I'll refer the USB port that goes into the computer as USB and the Port as the plug that goes into the iPod

  • Unable to get dataset while creating request

    Hi All, I am using OIM 11g. I want to provide resource attribute details during provision request. I have created a GTC with DBAT connector and I import the dataset xml successfully (varified by exporting the same). But while creating request I am no

  • ITunes installed but won't open

    I installed iTunes but when I try to open it all that happens is the user agreement appears.  I click on agree, the box disappears, but nothing ever happens.  Any ideas what my problem is?

  • Acrobat 9 Pro Error 148:3 You cannot use this product at this time

    Am running XP Pro SP3 with Acrobat 9.0 Pro Extended.  Until I installed Comodo antivirus software yesterday, Acrobat worked fine.  Now when I open Acrobat I get an error message similar to this:  "You cannot use this product at this time. You must re

  • Model not rendering with no UI in Applet

    I am currently working on an implementation of AutoVue that calls for the applet to have no UI and to just display the model. I have found that when I remove the UI form the applet the model does not render or display until I do something to the page