Results 1 to 11 of 11
  1. #1
    vikar is offline Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Question [ASK]Bugs of Java or Wrong Code?

    Dear All,
    What this is bugs of Java or me not to understand java programming, this my piece code :
    Java Code:
    String kode = txtKode.getText();
            String nama = inputNama.getText();
            String keterangan = inputKeterangan.getText();
            
            try {
                Connection c = KoneksiMySql.getKoneksi();
                String sql = "UPDATE UNIT SET NAMA=?, KETERANGAN=?, WKT_INPUT=now() WHERE KODE=?";
                PreparedStatement p = c.prepareStatement(sql);
                
                p.setString(1, nama);
                p.setString(2, keterangan);
                p.setString(3, kode);
                
                p.executeUpdate();
                p.close();
                JOptionPane.showMessageDialog(null, "Data Berubah",
                        "Pemberitahuan", JOptionPane.INFORMATION_MESSAGE);
            } catch(SQLException e) {
                System.out.println("Error : " + e);
                JOptionPane.showMessageDialog(null, "Proses Rubah Unit Gagal",
                        "Pesan Error", JOptionPane.ERROR_MESSAGE);        
            }finally {
    	    inputNama.setText(null);
    	    inputKeterangan.setText(null);
                btnTambah.setEnable(true);
                btnHapus.setEnabled(false);
                btnRubah.setEnabled(false);
                inputNama.requestFocus();
            }
    JOptionPane is Show and no error appears but data in database does not change, and code in block finally not executed.
    i'm use jInternalFrame, first run Only 'Add Button, Search Button' enable and other button are disable, then when 'Search Button' is clicked and open other jInternalFrame and get data form database, 'Add button' Disable and 'Delete Button, Change Button' are Enable. that my piece code on Change Button ActionPerformed.

    Please it's support.
    Thanks,
    Best & Regrads.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: [ASK]Bugs of Java or Wrong Code?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    vikar is offline Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Default Re: [ASK]Bugs of Java or Wrong Code?

    Quote Originally Posted by DarrylBurke View Post
    ya, I posted on a few forums to get the answer. because sometimes if just post on one forum, I did not get the answer of my problem.

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: [ASK]Bugs of Java or Wrong Code?

    Crossposting isn't a problem, but it is polite to inform people that you have done so.
    Many of us participate in more than one forum and it's annoying to spend time producing an answer only to load up one of the other forums and find someone had already answered it yesterday.

    For your actual problem, stick a load of debugging code in that try/catch block so you can see where it gets to and with what values.
    Also change the catch so it uses printStackTrace() as well, since printing 'e' won't get you all the information about the exception.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: [ASK]Bugs of Java or Wrong Code?

    Quote Originally Posted by vikar View Post
    ya, I posted on a few forums to get the answer. because sometimes if just post on one forum, I did not get the answer of my problem.
    If the forum is in any way active, 99/100 times that would mean that you have asked the question in such a way that people either can't answer it or don't want to answer it. In stead of posting it just everywhere in the hope that someone is clever enough to guess what you're trying to say, perhaps rethink the question and ask it in another way, or add more information.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: [ASK]Bugs of Java or Wrong Code?

    Just by reading the topic title, the answer 'wrong code' is correct by a probability of over 99%.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: [ASK]Bugs of Java or Wrong Code?

    It would be quite an achievement if a Java novice is going to find a bug in core Java where thousands of expert Java programmers that use it to write vastly complex software systems do not.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    vikar is offline Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Default Re: [ASK]Bugs of Java or Wrong Code?

    maybe I should share my Java Project, where the problem was there with you guys. Every problem in java I can usually solve by studying articles related to the problem. but it is rather difficult because Java does not tell me about the problem. and the problem is quite strange.

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: [ASK]Bugs of Java or Wrong Code?

    Every problem in java I can usually solve by studying articles related to the problem.
    Weird. I usually solve problems by investigating the situation through proper debugging and reasoning about it; the very last thing I do is apply the word "weird" - its always something perfectly reasonable, you just need to figure out what you're doing wrong that is causing behavior you do not expect. Articles don't tend to cover the programming mistakes I'm making so they don't help me very much.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: [ASK]Bugs of Java or Wrong Code?

    Quote Originally Posted by vikar View Post
    maybe I should share my Java Project, where the problem was there with you guys. Every problem in java I can usually solve by studying articles related to the problem. but it is rather difficult because Java does not tell me about the problem. and the problem is quite strange.
    Have you tried debugging it as I suggested in post #4?
    Because that's all we'd have to do...and it would be better for you to do the leg work.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    vikar is offline Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Default Re: [ASK]Bugs of Java or Wrong Code?

    Thanks for the support, i have solve my problem. The problem it's located in Instance of jInternalFrame.
    I Love Java ^_^.

Similar Threads

  1. Java ImageIO Method | What's wrong in my code !!!
    By ProgrammerIsaac in forum New To Java
    Replies: 6
    Last Post: 05-22-2012, 08:44 PM
  2. What is wrong in this code of java
    By kank635 in forum New To Java
    Replies: 1
    Last Post: 01-16-2012, 09:41 PM
  3. Please look at my java code and tell me what's wrong
    By xcointoss in forum Advanced Java
    Replies: 3
    Last Post: 10-22-2010, 04:15 AM
  4. what wrong with my java code
    By MAXZZXAM in forum New To Java
    Replies: 3
    Last Post: 11-19-2009, 09:38 AM
  5. My first Java project, encountering bugs
    By beatzz in forum New To Java
    Replies: 1
    Last Post: 03-17-2009, 08:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •