Bug in the program!!!

i have a server file as
//TCPServer.java
import java.io.*;
import java.net.*;
class TCPServer
public static void main(String argv[]) throws Exception
String clientSentence;
String capitalizedSentence;
ServerSocket welcomeSocket = new ServerSocket(6789);
while(true)
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient =
new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
clientSentence = inFromClient.readLine();
System.out.println("Received: " + clientSentence);
capitalizedSentence = clientSentence.toUpperCase() + '\n';
outToClient.writeBytes(capitalizedSentence);
and a client file as
//ViewEntry.java
* @author Chinmay
import java.awt.*;
import java.awt.event.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.util.*;
import java.sql.*;
import java.io.*;
import java.net.*;
public class ViewEntry extends JFrame implements ActionListener,ItemListener {
JTable table;
JButton save,view;
JPanel panel;
JScrollPane jsp;
Vector col,data,row;
JMenuBar mbar;
JMenu file;
JMenuItem sav;
Connection connection;
PreparedStatement ps;
ResultSetMetaData rmeta;
ResultSet rs;
static String tableName;
Dimension screen;
JComboBox projects;
public ViewEntry(){
//super("View Data",true,true,false,true);
panel = new JPanel();
this.getContentPane().add(panel);
save = new JButton("Save");
projects = new JComboBox();
view = new JButton("View");
panel.setLayout(null);
panel.add(projects);
projects.setBounds(300,50,150,20);
panel.add(view);
panel.add(save);
save.addActionListener(this);
save.setBounds(600,100,100,25);
view.setBounds(500,50,100,25);
view.addActionListener(this);
//panel.add(save);
save.addActionListener(this);
mbar = new JMenuBar();
file = new JMenu("File");
sav = new JMenuItem("Save");
mbar.add(file);
file.add(sav);
sav.addActionListener(this);
this.setJMenuBar(mbar);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection= DriverManager.getConnection("jdbc:odbc:ibc");
ps = connection.prepareStatement("Select * from Projects");
rs = ps.executeQuery();
while(rs.next()){
projects.addItem(rs.getString(2)+"_"+rs.getString(7));
catch(Exception ex){
JOptionPane.showMessageDialog(this, ex);
/*screen = StartPage.desktop.getSize();
int w = 700;
int hi = 600;
int x = (screen.width - w) / 2;
int y = (screen.height - hi) / 2;
this.setBounds(x, y, w, hi);*/
this.setVisible(true);
this.setSize(800,800);
// this.setMaximizable(true);
public static void main(String[] args){
new ViewEntry();
public void actionPerformed(ActionEvent e) {
if(e.getSource()==view){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc:odbc:ibc");
tableName = (String)projects.getSelectedItem();
ps = connection.prepareStatement("Select * from "+tableName);
rs = ps.executeQuery();
rmeta = rs.getMetaData();
int colcount = rmeta.getColumnCount();
col = new Vector(colcount);
data = new Vector();
for(int i=1;i<=colcount;i++){
col.add(rmeta.getColumnName(i));
while(rs.next()){
row = new Vector(colcount);
for(int i=1;i<=colcount;i++){
row.add(rs.getString(i));
data.add(row);
table = new JTable(data, col);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
jsp = new JScrollPane(table, v, h);
panel.add(jsp);
jsp.setBounds(150,80,500,400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, ex);
if(e.getSource()==save){
try {
transfer();
} catch (Exception ex) {
System.out.println("Error : "+ex);
public void itemStateChanged(ItemEvent e) {
if(e.getSource()==projects){
tableName = (String)projects.getSelectedItem();
JOptionPane.showMessageDialog(this, tableName);
private void transfer() throws Exception {
String sentence;
String modifiedSentence;
Socket clientSocket = new Socket("localhost", 6789);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
sentence = "Hi";
outToServer.writeBytes(sentence+"\n");
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
clientSocket.close();
i want to send a string to the server file and then the server converts the string to upper case and sends again back to client. This program is working fine but the problem when i click the save button the client sends string 2 times and sever responds 2 times. Please tell me what the exact problem is. Please help me

Please repost your code using the CODE button above to preserve its formatting. Nobody is going to review it in its current state. But you do need to be aware that you have added 'this' as an ActionListener at least 3 times instead of once, so getting multiple events on the same action isn't too surprising.

Similar Messages

  • Early today Alt, Ctr and Click and drag changed the brush size. Now it makes the move tool work. Anyone have this problem. I think Adobe had an update and put a bug in the program.

    Early today Alt, Ctr and Click and drag changed the brush size. Now it makes the move tool work. Anyone have this problem. I think Adobe had an update and put a bug in the program.

    Which version of photoshop and operating system are you using?
    windows:
    Alt + right click + drag left or right
    mac:
    Control + Option + left click + drag left or right

  • Mac OS X Mountain lion bug sometimes the programs don't like to lunch and I unplug the power cord what shall i do

    Mac OS X Mountain lion bug sometimes the programs don't like to lunch and I unplug the power cord what shall i do

    Here are some suggestions for getting the best results from this site.
    If you're not comfortable with English, it may be best to post in your native language. Others can use automatic translation, if necessary, to help them understand you. They may reply in their native language, and then you can do the same to understand them.
    Google Translate
    Screenshots can help overcome a language barrier. To upload an image, click the camera icon in the message editor on this page.
    Give details of the problem. A statement such as "it doesn't work" conveys no information. If it did work, you wouldn't be here. Instead, you should post something like this: "I did A; I was expecting B; but I got C instead." Include the complete text of any error messages you saw and where you saw them: in an application window, a CrashReporter window, a log, or whatever. Also include the steps you’ve taken yourself, if any, to try to resolve the issue. If the problem is of recent origin, did you make any changes to your setup just before you first noticed it? Is the problem reproducible or intermittent? That is, does it always manifest itself when you take a certain action, or only at unpredictable times?
    Before posting, ask yourself whether it’s likely that you are the the only person ever to have had this problem. If not, search the discussions for answered questions similar to yours. If you found any pertinent information, but it didn't help, include details.

  • How do u remove foxfire "persona" due to some kind of bug in the programming? It is making our computer extermly slow!!!!

    How do you remove just the persona , due to big bad bugs, making our computer unusable?

    You can uninstall your current Persona and revert to the Default theme (Firefox or Tools > Add-ons > Appearance).
    See
    * [[Personas]]
    * [[Using themes with Firefox]]

  • When I try to insert several pdf files into an initial one, they consistently are attached in reverse order, no matter how I instruct the program. How do I correct this?

    I am working with Acrobat X Pro. I open a pdf, then try to insert several files, in a specific order, into the first one. No matter whether I instruct it to place the files after the first, last or name a page number, the files are inserted in reverse order after the initial file. How do I overcome this problem?

    Thanks Bill !! for providing the simple answer - this has saved me much work.  I always assumed that Acrobat would either a) sort the inserted files alphanumerically or b) use the sort order of the OS's file selector.  The c) answer of inserting the files in the reverse order of the OS file selector (since Acrobat will reverse that order) eluded me until now.  
    It's clearly a bug in the program, I'm using Acrobat X Pro, but had the exact same problem with Acrobat 7 - never occurred to me to sort the file listing in reverse alphanumeric order in order to have Acrobat insert them in correct alphanumeric order.
    Thank!

  • The program 'name here' received an X Window System error.

    After the latest xorg update I keep on getting these errors when starting up programs - here's an example of xchm:
    The program 'xchm' received an X Window System error.
    This probably reflects a bug in the program.
    The error was 'BadAlloc (insufficient resources for operation)'.
      (Details: serial 210 error_code 11 request_code 147 minor_code 5)
      (Note to programmers: normally, X errors are reported asynchronously;
       that is, you will receive the error a while after causing it.
       To debug your program, run it with the --sync command line
       option to change this behavior. You can then get a meaningful
       backtrace from your debugger if you break on the gdk_x_error() function.)

    There have already been reports of BadAlloc errors.  Perhaps they apply to you too.
    http://bugs.archlinux.org/task/9254
    http://bbs.archlinux.org/viewtopic.php?id=42541

  • The program 'xchat' received an X Window System error. [SOLVED]

    amg ~ $ xchat
    The program 'xchat' received an X Window System error.
    This probably reflects a bug in the program.
    The error was 'BadImplementation (server does not implement operation)'.
    (Details: serial 310 error_code 17 request_code 145 minor_code 5)
    (Note to programmers: normally, X errors are reported asynchronously;
    that is, you will receive the error a while after causing it.
    To debug your program, run it with the --sync command line
    option to change this behavior. You can then get a meaningful
    backtrace from your debugger if you break on the gdk_x_error() function.)
    Why this is happening? Anyone had this problem?
    Regards
    EDIT: Well, it is a bug in intel driver http://bugs.archlinux.org/task/8976
    Last edited by alexmgarcia (2007-12-20 00:42:44)

    There have already been reports of BadAlloc errors.  Perhaps they apply to you too.
    http://bugs.archlinux.org/task/9254
    http://bbs.archlinux.org/viewtopic.php?id=42541

  • I found the solution to a Mavericks bug on the Mail program. How can I share it? Several of my mail boxes stopped functioning properly when I updated to Mavericks. After long hours, I discovered that if I change the name of the mailbox, the content works.

    I found the solution to a Mavericks bug on the Mail program. How can I share it? Several of my mail boxes stopped functioning properly when I updated to Mavericks. The title of the mails stored in the mailbox appear, but the content was unavailable.
    After 4 long hours at the phone with the Apple staff unable to help me, I discovered that if I change the name of the mailbox, the contents of the mails stored there become available.
    Please, make this solution available to other people!

    You have found the the way to share it.   Include your problem and its solution in a forum post in the Mavericks forums.   Then mark you own post with a green solved star.
    Note.  You won't get any points for that; points are only awarded where you mark someone else's post as either helpful or solved.

  • When my iPod Touch is connected to my Mac, and I select Update to update the software of my iPod Touch, I get a message saying that my iTunes software is current, but it will not update my iPod Touch software.  Is there a bug in the iPod program?

    When my iPod Touch is connected to my Mac, and I select Update to update the software of my iPod Touch, I get a message saying that my iTunes software is current, but it will not update my iPod Touch software.  Is there a bug in the iPod program?

    If you have the first gen ipod touch as your information shows, then you would have to buy a software update:
    Purchasing iOS 3.1 Software Update for iPod touch (1st generation)

  • Since moving to Maverick and the new updated of Keynote, I have a constant problem when typing in a text box, the program crashes. Is there a bug fix for this. Drives me nuts.

    Since moving to Maverick and the new updated of Keynote, I have a constant problem when typing in a text box, the program crashes. Is there a bug fix for this. Drives me nuts. Like many who can type quite quickly but at secretarial level, the text box freezes, nothing works and you know what's coming...crash!
    This is most annoying. Is there bug fixes for this. Apparently I have the current updates and this problem still exists. Is it a Maverick bug or Keynote.
    Barry

    How did you install Mavericks, as an update ontop of the previous OS or did you wipe the drive and install clean?

  • Why my iphone produces a bug after it renew for OS5.1.1. The bug is when I use message, type a Chinese word, and then using a releveant word, then the program automately closes. Every time I try the same procedure, it definitely closes.

    Why my iphone produces a bug after it renew for OS5.1.1. The bug is when I use message, type a Chinese word, and then using a releveant word, then the program automately closes. Every time I try the same procedure, it definitely closes.

    Nobody knows? Not even administrators?
    Please it would be really nice to have help on that to take all the benefit of the remote app.
    Thank you very much in advance.

  • I think there is a very annoying bug after the latest update of firefox, can I talk to someone, or chat with someone so I can get rid of it

    Since the latest auto update of my firefox browser I am experiencing strange issues. Every evening when I stop working, I close my browser (closing all the tabs that I am working on and in the morning, I restore the session) . For many years everything worked just fine ... untill after the last auto update of the firefox browser .. all of a sudden a got 302 errors ( a blank page with the description 302 and I believe "page moved here" or something to that extend ... i try to click the link and get nowhere.
    I first noticed it on a few wordpress pages (backend ) that I was working on and which were restored from the previous day ...
    thinking it was a server error, since we have several vps and dedicated servers .. i contacted the company who hosts our servers ..
    they looked into it and apparently .. there were no issues on the server side and neither on that particular computer ... but our server hosts told us .. that it is probably browser related and seemed to have something to with a bug with the cache of the browser
    we didn't know what to do .. it was very annoying .. but at that point it only happened once on a hew pages .. so we decided to see what happened the next time
    Next time we did not restore a session with wordpress pages .. but with the google search engine open and on a few other tabs logged into social media .... and as was saidn by our server hosts it was indeed not related to work that we did on pages on our servers ... since that time even the google search engine homepage ... showed us ... moved here
    Can you pease look into it and fix this .. we are doing the same thing as many years on the same computer also a few years .. so it is not anything we do wrong either .. it is most definitely browser related
    so can you please fix it asap .. since when we work on wordpress .. that is not the only thing that goes wrong .. we also have difficulty uploading updates ... when updating sometimes after the update of any particular change on a wordpress page is done ... we are also redirected to a blank page .. so the updated page does not want to load ... in that case we have use our back button ...
    which sends us back to the right page ... but with the old data on it ... then we have to refresh that page .. and only then we see the page updated ... so it seems that there is an issue in both direction with the caching of the browser after the last update
    Kind regards,
    Robert

    uninstalled firefox ....deleted all files still remaining under mozilla firefox directory in program files ... to avoid having to reprogram all my settings, reisntall all addons as well .. I did not remove anything from mozilla firefox that is stored in either appdata or under the windows users directory (if any)
    ... the as suggested reinstalled the latest version of the firefox browser using the link you provided in the email ..; tested and several issues still remain present and unresolved ....
    so please this is urgent or I will have to jump browsers and start using chrome .. because we work 14 hours a day 6 (sometimes 7) days a week, to get ready for the launch of our newest venture and we cannot lose that much days on browser related issues ... so please instead of putting me through week long step process .. of do this .. do that .. can you please actually look into the issue from your end .. I use firefox for so many, many years thta I deserve this kind of support .. thnx Robert

  • Problem caused the ptrogram to stop working correctly.  Windows will close the program and notify you if a solution is available.  This is what I am getting every time I try to open Photoshop

    What am i doing wrong?  I removed the program and downloaded it again, but I keep getting this. 

    What does the detailed crash report say? Check the windows system event viewer for details.
    And update your video card driver from the GPU maker's website - because most of the crashes on launch are due to people running really outdated video card drivers and not picking up the past few years worth of bug fixes.

  • Find a BUG on the SOA Suite ( Internationalizing Problem)

    I am a java developer in Thailand.
    I have 4 Java Certifications - SCJP, SCWCD, SCBCD, SCJWSD.
    I meet something wrong ("bug") when I play with Oracle SOA Suite.
    About my technical software :
    -I use the Oracle Database XE (Universal).
    (I cannot use the HTML DB to run your script from soademo_101310_preview - it's give me the error messages so I change to run the SQL from command. Although running the SQL script from the command line is O.K., the command window is not support the Thai language. It appear in Alien language that I cannot read.I try to change the command window option but It has only 2 font choices. Thus I cannot still do with Thai language in the command window.)
    In control panel, the regional and Language Option, I set the standard and format to Thai (including Language for the non-Unicode program in Advanced Tab).
    I am successful both insallation and deploy the SOA book application.
    I follow the instruction in Oracle SOA Suite Quick Start Guide, 10g Release 3 (10.1.3.1.0).
    At the page 39, I find a BUG.
    My created date on the BPM Worklist is wrong !!!
    My computer time is 10 &#3585;&#3633;&#3609;&#3618;&#3634;&#3618;&#3609; ( September in Thai language) 2549 (Buddhist Time).
    But the date I see in the BPM Worklist is 10 &#3585;&#3633;&#3609;&#3618;&#3634;&#3618;&#3609; ( September in Thai language) 3635 (Buddhist Time).
    You can see the image at http://img178.imageshack.us/img178/5487/datehp3.jpg.
    I have 3 questions :
    1. How can I add the Thai font in SQL command line window (SQL*Plus) in Oracle XE ?
    2. Why does the HTML DB not support to run the uncomplete sql script ?
    3. Have any suggestion to correct the time problem. ( Internationalizing Problem) ?
    Thank you very much.

    This is not a bug.
    The timezone is based on the user profile.
    You are using jcooper, whose timezone setting by default is set to be
    <timeZone>America/Los_Angeles</timeZone>
    Please double check the
    ORACLE_HOME\OraBPEL_1\bpel\system\services\config\users-properties.xml
    jcooper should have settings like this by default:
    <name>jcooper</name>
    <description>Demo User</description>
    <email></email>
    <title>Loan Agent 1</title>
    <firstName>James</firstName>
    <lastName>Cooper</lastName>
    <manager>jstein</manager>
    <timeZone>America/Los_Angeles</timeZone>
    <languagePreference>en-US</languagePreference>
    <notificationPreferences>Mail</notificationPreferences>
    Message was edited by:
    user530868
    Message was edited by:
    user530868

  • After I purchased the creative cloud, I receive an error message when trying to use premier pro cc 2014.  It states "Adobe Premiere Pro 2014.2 has stopped working.  A problem has caused it to stop working.  Windows will close the program and notify you of

    After I purchased the creative cloud, I receive an error message when trying to use premier pro cc 2014.  It states "Adobe Premiere Pro 2014.2 has stopped working.  A problem has caused it to stop working.  Windows will close the program and notify you of a solution."  When I used the trial I never received this message.  Now after purchasing it I receive this error each time I open PP and am unable to use. it.  Any ideas or support to fix this issue?

    What does the detailed crash report say?
    And have you updated your video card drivers from the GPU maker's website? (most crashes on launch are due to bugs in out of date video card drivers)

Maybe you are looking for

  • Foreign currency Payment using foreign currency bank account

    Hi, We have the following requirement: Functional currency : GBP Bank Account :USD Need to make payments in CAD Since the bank account is not in functional currency we are unable to make that multi currency payment enabled. Users do not want to creat

  • CRM line item status not updated when delivery is deleted in ECC

    Hi All, When order is created in CRM it gets replicated to ECC.When delivery is created in ECC, the System Status in CRM  at the line item level is changed to completed and also Delivery completed status is created in CRm.. Now when we delete the del

  • Infosets in multiprovider

    Hi  all, I am going to create multiprovider on  infosets . so how the data is going to handle  in this situation ?    and please let me  know any  special steps  that i need to take while  creating  this  multiprovider.

  • Trouble seeing/using apps in EAS

    Hi Folks, I just did a first time install/configure of Essbase 9.3.1 on a Win2ks sp2 pc. Opening the EAS console, in Enterprise View I expected to see the 'Essbase Servers' directory pre-populated with at least one sample server and associated applic

  • Which would you keep, which would you sell, and why?

    This kind of question might not be totally appropriate for this forum, but here goes anyhow. If it's really off-topic, I suppose the mods can delete it, but I am really having a hard time with this decision. I am thinking of selling off a couple of l