Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Can anybody correct the code?

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can anybody correct the code?

    The code is

    Node codeiso3= node.selectSingleNode("isoAlpha3");
    Node capital= node.selectSingleNode("capital");
    System.out.println(codeiso3.getText() + capital.getText());
    String tempstring="UPDATE country_details SET capital = ? WHERE codeISO3 = ? ;";

    System.out.println(tempstring);
    z=conn.prepareStatement(tempstring);
    String x = "\""+capital.getText()+"\"";
    String y = "\""+codeiso3.getText()+"\"";
    System.out.println(x);
    System.out.println(y);
    z.setString(1,x);
    z.setString(2,y);
    z.executeUpdate (tempstring);

    The Error is

    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorEx ception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? WHERE codeISO3 = ?'

    Im getting the nodes correctly.There is error in including the string which i got within double quotes.I have tried various methods to include double quotes but in vain.Can anybody say how to do this?

    Thankyou in advance!!!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Can anybody correct the code?

    Check you query...semicolons are not necessary when using JDBC

Similar Threads

  1. Replies: 2
    Last Post: August 2nd, 2011, 09:11 AM
  2. Is this correct.Am I close? Help please
    By eagle09 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 26th, 2011, 08:26 AM
  3. I still have errors. Can you PLEASE correct my code?!
    By sam30317 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 6th, 2011, 07:10 AM
  4. [SOLVED] Code is correct, but incorrect output?
    By moodycrab3 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 6th, 2011, 02:32 PM
  5. Is My answers correct??
    By Java.Coder() in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 28th, 2010, 06:22 AM