Why this simple code doesn't work?????

i get error "java.sql.SQLException: Operation not allowed after ResultSet closed "
try{
            Class.forName("com.mysql.jdbc.Driver");
            Connection dbcon = DriverManager.getConnection("jdbc:mysql://localhost:3306/db?user=user&password=pasw&useUnicode=true&characterEncoding=utf-8");
            String query = "SELECT * FROM  data where parent_id='xxsds^1'";
            Statement statement = dbcon.createStatement();
            ResultSet rs = statement.executeQuery(query);
            while(rs.next())
                String name = rs.getString("name");
                String query2 = "SELECT * FROM  data where parent_id='"+name+"'";
                statement.execute(query2);
                ResultSet rs2 = statement.getResultSet();
                while(rs2.next())
                    String name1 = rs2.getString("name");
        catch(Exception ex){out.println(ex);}thanks a lot

You need to use two separate statments if you're going to interleave the queries like that. I'd think you could get by with a single query and a join though, but I didn't actually look at what your queries are doing.
Also, you should use PreparedStatement, a "?" parameter, and PS's setString method, rather than a plain old Statement where you have to maually handle string quoting.

Similar Messages

  • Simple? can anyone tell why this simple btn doesn't work?

    Trying to write my own simple disabling button class (with
    some help from friend - thanks LuigiL)
    So, why does my button not turn off when clicked? it runs the
    deinitializeBehavior function but the removeEventListeners are not
    actually being removed...
    I don't know why but could this possibly be a graphics issue?
    Thanks in advance

    HAH! OK - I am starting to get this a little.
    Thank you St. LuigiL. You are my Obie-wan: the force is
    strong with you.
    I made a Main.as document class and now the whole thing works
    like a charm! I was wondering if it was necessary to do so - and it
    was.
    In my OCD I am constantly striving to keep my classes to a
    bare minimum (if I could write everything on one page I would.)
    I very much appreciate your incredible help and support.
    BAM

  • Why does this java code doesn't work on my pc?

    for example:
    package one;
    public class Alpha {
    //member variables
    private int privateVariable = 1;
    int packageVariable = 2; //default access
    protected int protectedVariable = 3;
    public int publicVariable = 4;
    //methods
    private void privateMethod() {
    System.out.format("privateMethod called%n");
    void packageMethod() { //default access
    System.out.format("packageMethod called%n");
    protected void protectedMethod() {
    System.out.format("protectedMethod called%n");
    public void publicMethod() {
    System.out.format("publicMethod called%n");
    public static void main(String[] args) {
    Alpha a = new Alpha();
    a.privateMethod(); //legal
    a.packageMethod(); //legal
    a.protectedMethod(); //legal
    a.publicMethod(); //legal
    System.out.format("privateVariable: %2d%n",
    a.privateVariable); //legal
    System.out.format("packageVariable: %2d%n",
    a.packageVariable); //legal
    System.out.format("protectedVariable: %2d%n",
    a.protectedVariable); //legal
    System.out.format("publicVariable: %2d%n",
    a.publicVariable); //legal
    As you can see, Alpha can refer to all its member variables and all its methods, as shown by the Class column in the preceding table. The output from this program is:
    privateMethod called
    packageMethod called
    protectedMethod called
    publicMethod called
    privateVariable: 1
    packageVariable: 2
    protectVariable: 3
    publicVariable: 4
    when above example runs on my pc:
    it works below description:
    D:\javacode>javac Alpha.java
    D:\javacode>java Alpha
    Exception in thread "main" java.lang.NoClassDefFoundError: Alpha (wrong name: on
    e/Alpha)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    why it runs wrongly and who can help me?
    thanks

    if i runs it below:
    D:\javacode>javac one\Alpha.java
    D:\javacode>java one.Alpha
    privateMethod called
    protectedMethod called
    protectedMethod called
    privateVariable: 1
    packageVariable: 2
    protectedVariable: 3
    publicVariable: 4
    it runs well!

  • Can someone help me why this quick sort doesn't work

    public class QuickSortII {
         static void sort(int a[], int lo0, int hi0) {
            int lo = lo0;
            int hi = hi0;
            if (lo >= hi) {
                return;
            int mid = a[(lo + hi) / 2];
            while (lo < hi) {
                while (lo<hi && a[lo] < mid) {
                    lo++;
                while (lo<hi && a[hi] >= mid) {
                    hi--;
                if (lo < hi) {
                    int T = a[lo];
                    a[lo] = a[hi];
                    a[hi] = T;
            if (hi < lo) {
                int T = hi;
                hi = lo;
                lo = T;
            sort(a, lo0, lo);
            sort(a, lo == lo0 ? lo+1 : lo, hi0);
        static void sort(int a[]) {
            sort(a, 0, a.length-1);
         static public void main(String[] args) {
              int a[] = new int[20];
              a[0] = 18;
              a[1] = 11;
              a[2] = 12;
              a[3] = 4;
              a[4] = 20;
              a[5] = 5;
              a[6] = 1;
              a[7] = 3;
              a[8] = 16;
              a[9] = 8;
              a[10] = 7;
              a[11] = 17;
              a[12] = 9;
              a[13] = 6;
              a[14] = 19;
              a[15] = 2;
              a[16] = 13;
              a[17] = 15;
              a[18] = 10;
              a[19] = 14;
              sort(a);
              for (int j = 0; j < 20; j++) {
                   System.out.print(a[j] + " ");
    }it doesn't sort the list

    it doesn't sort the list Please explain why you think it should. Doing so will help you understand the code.
    ~

  • Can _you_ see why this HTTP POST doesn't work?

                URL url = new URL(SOAPurl);
             URLConnection connection = url.openConnection();
                httpConn = (HttpURLConnection)connection;          
             httpConn.setRequestProperty( "Content-Length", String.valueOf( byteArray.length ));                  httpConn.setRequestProperty("Content-Type","text/xml;charset=ISO-8859-1");
                httpConn.setRequestMethod( "POST" );
                httpConn.setDoOutput(true);
                httpConn.setDoInput(true);
                // Everything's set up; send the XML that was read in to b.
                OutputStream out = httpConn.getOutputStream();
                out.write( b );
                out.close();The code above will activate my servlet's doGet() method, not doPost()
    shouldn't the setRequestMethod("POST") be enough to indicate that this is a POST not a GET?
    - bjorn

    Using the code found here: http://www.javaworld.com/javaworld/jw-03-2001/jw-0323-traps.html
    I am able to invoke the doPost() method in my servlet, but the POST data is empty, here is what my servlet prints to standard out:
    Post Recieved
    Header Namer: content_length -- Value : 35
    Header Namer: user-agent -- Value : Java/1.4.1_01
    Header Namer: host -- Value : 127.0.0.1:8080
    Header Namer: accept -- Value : text/html
    Header Namer: accept -- Value : image/gif
    Header Namer: accept -- Value : image/jpeg
    Header Namer: accept -- Value : *; q=.2
    Header Namer: accept -- Value : */*; q=.2
    Header Namer: connection -- Value : keep-alive
    Header Namer: content-type -- Value : application/x-www-form-urlencoded
    Header Namer: content-length -- Value : 35
    InputStream.isavailable()=0
    What we recieved: (0)
    Servlet doPost() method:
        public void doPost( HttpServletRequest req, HttpServletResponse resp ) {
            System.out.println("Post Recieved");
            MimeHeaders headers = getHeaders(req);
            Iterator it = headers.getAllHeaders();
            while(it.hasNext()) {
                MimeHeader header = (MimeHeader)it.next();
                System.out.print("Header Namer: " + header.getName());
                System.out.println(" -- Value : " + header.getValue().toString());
            try {
                InputStream is = req.getInputStream();
                byte[] b = new byte[]{};
                System.out.println("InputStream.isavailable()=" + is.available());
                int numbytesread = is.read(b,0,is.available());
                System.out.println("What we recieved: (" + numbytesread + ")\n" + b.toString());
                PrintWriter out = resp.getWriter();
                System.out.println("Running runQuery() - "+queries.get(dbQueryNum));
                String xml = dbconn.runQuery(queries.get(dbQueryNum).toString());
                //System.out.println("returned from runQuery()\n"+xml);
                System.out.println("size of returned XML: "+xml.length());
                out.write(xml);
            } catch (IOException ioe ) { // throwed by getInputStream()
                ioe.printStackTrace();
        }

  • Why this simple assingment is not possible in Generics ?

    Hi
    Just curious to know why this simple conversion does not work and requires casting ?
    List<? super Integer> list = new ArrayList<Integer>();
    List<? super Number> listN = list; //Requires Casting
    List<? extends Number> listExNu = new ArrayList<Number>();
    List<? extends Integer> listExIn = listExNu; //Requires CastingAs per my understanding ,
    A List<? super Number> can fit inside a List<? super Integer> ...
    So what really happens here to force casting ? Any ideas ?

    ejp wrote:
    List<? super Integer> list = new ArrayList<Integer>();The only two classes that are superclasses of Integer are Number and Object.Not quite. Please note that the clause *? super Integer* is inclusive, i.e. it also matches List<Integer>.
    Additionally, it matches all interfaces implemented by Integer. Thus, the following types can be assigned to list:
    List<Integer>
    List<Serializable>
    List<Comparable<Integer>>
    List<Comparable<? extends Integer>>
    List<Comparable<? super Integer>>
    List<Comparable<? extends Number>>
    List<Comparable<? extends Serializable>>
    List<Comparable<?>>
    List<Number>
    List<Object>And the following types can be assigned to listN:
    List<Serializable>
    List<Number>
    List<Object>Since the latter is a genuine subset of the former, an implicit conversion such as listN = list is impossible.

  • Why forum home page doesn't working?

    Hai friends, can anyone tell me why this forum homepage doesn't work properly and it shows Opps the page can't find error.

    -> See these:
    * http://www.ehow.com/how_6609141_remove-bearshare-spyware.html
    * http://www.fanhow.com/answers/question-77222-how-to-delete-bearshare-search-from-firefox
    You can look for a "Mediabar" program under "Control Panel > Programs and features"
    -> See also these forum threads about BearShare:
    * https://support.mozilla.com/en-US/questions/762144
    * https://support.mozilla.com/en-US/questions/700250
    Check and tell if its working.

  • How to use documentbeforesaved method? And why my code doesn't work in template files?

    Can someone help me with these two codes?
    ----Beginning of code 1-------------
    Private WithEvents App As Word.Application
    Private Sub Document_Open()
    Set App = Word.Application
    End Sub
    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox("BeforeSave")
    End Sub
    --------------End of the code----------------
    Beginning of code 2--------------- Code 2 is from https://msdn.microsoft.com/en-us/library/office/ff838299(v=office.15).aspx
    Public WithEvents appWord as Word.Application 
    Private Sub appWord_DocumentBeforeSave _ 
     (ByVal Doc As Document, _ 
     SaveAsUI As Boolean, _ 
     Cancel As Boolean) 
     Dim intResponse As Integer 
    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox("BeforeSave")
    End Sub
    In the first code, they have:
    Private Sub Document_Open()
    Set App = Word.Application
    End Sub
     I test these two codes in "This document" object, and I find out the first code works but the second code are not!
    Why second code doesn't work?
    Extra question: I am using microsoft 2013. I insert this code into a macro-enabled template. But when I am about to save my file I am expecting these code works. However, they didn't work!
    Thank you for solving these problem for me!

    Hello,
    Please note that the code snippet 2 in your post is different from the code snippet in the MSDN document. Also please read the comments of the MSDN code sample:
    This example prompts the user for a   yes or no response before saving any document.
    This code must be placed in a   class module, and an instance of the class must be correctly initialized to   see this example work; see
    Using Events with the Application Object for   directions on how to accomplish this.
    Public WithEvents appWord   as Word.Application
    Private Sub   appWord_DocumentBeforeSave _
     (ByVal Doc As Document, _
     SaveAsUI As Boolean, _
     Cancel As Boolean)
     Dim intResponse As Integer
     intResponse = MsgBox("Do you really   want to " _
     & "save the document?", _
     vbYesNo)
     If intResponse = vbNo Then Cancel = True
    End Sub
    So the problem in your code snippet 2 is that you didn't put it into a class module and initialize the class module. If you just put it into ThisDocument, you have to initialize the word application object.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • The ussd code doesn't work on my iphon since i update to ios 7.0.3 what can i do for this problem?

    the ussd code doesn't work on my iphon since i update to ios 7.0.3 what can i do for this problem?

    Maybe
    SOLUTION: circle with red square Some Music Won't Play After...: Apple Support Communities

  • Why does my n81 doesn't work properly in Vodafone ...

    Why does my n81 doesn't work properly in Vodafone Live?? I can't download....etc

    Hi,
    I'm sorry to hear that you're having problems downloading from Vodafone Live.
    If you're able to access the pages of Vodafone Live then the settings in your handset are correct else you wouldn't get that far.
    It's possible that there's a problem with your account that’s restricting you from downloading which will need to be looked into. Rather then transferring your account details on the forum would it be possible for you to contact me via email by completing Vodafone Online Contact Forum following the link below.
    https://online.vodafone.co.uk/dispatch/Portal/appmanager/vodafone/wrp?_nfpb=true&_pageLabel=Page_Hel...
    Please fill in all the fields and include the code FIT135 to ensure that the email is directed to the forum Team.
    As soon as we receive your email we can look into this further for you.
    I look forward to hearing from you.
    Techgirl
    Vodafone UK

  • Why some contact forms doesn't work on some websites? We don't receive the submission form with the information?

    Why some contact forms doesn't work on some websites? We don't receive the submission form with the information?

    Hi Aish
    I wanted to check the following, but the URL is not found, you have another one?
    thanks
    Nicole
        4. Visit http://my-site.com/scripts/form_check.php in a web browser and make sure you see all green checkmarks. If some items do not display green checkmarks that means that the hosting server is not configured correctly to allow the Form widgets to send email messages to the address you've specified.
                    Contact your web-hosting provider about the server configuration problem. Describe the items that are not marked as green in the form check page, so that they can help you set up the servers to use the correct settings.
    Il giorno 9-set-2014, alle ore 16:11, Aishvarya Raj Rastogi <[email protected]> ha scritto:
    Why some contact forms doesn't work on some websites? We don't receive the submission form with the information?
    created by Aishvarya Raj Rastogi in Help with using Adobe Muse CC - View the full discussion
    Hi Nicole,
    What is the "From" email address in your form?
    Also, have you checked the spam folder?
    Please check the following posts as well :
    https://forums.adobe.com/docs/DOC-3581
    Re: PHP mail may be disabled or incorrectly configured on the web server.
    Regards,
    Aish
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6714281#6714281
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Help with using Adobe Muse CC by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • ISF/javascript code doesn't work for non-English RequestCenter proile

    ISF/javascript code doesn't work for non-English RequestCenter proile
    Hello,
    I am not sure if i posted the same question before also. We have some customers who have set thier language profile in newScale requestcenter to French. However, all the javascript customizations configured on the service forms do not function for 'French' as a Langauge preference. Has anyone encountered the similar issue before and can anyone please suggest a solution for it?
    Thanks,
    Mihir

    we had a similar issue a while back where the Approval button was not working in Spanish, needed a fix from nS for it
    The way to fix this would be to locate the language XML file, override the French caption with Submit and on onLoad write a global JS that would write the button label again (not so sure about this)
    But really its an major defect and they should be able to fix it.

  • Why this character \ it is not working in action scrip?

    Hi...
    Why this character \ it is not working in action scrip? And
    how can I solve it?
    on (release) {
    text.text = text.text + "l"
    Please your help ASAP
    thank you

    yea, that's true, but I don't think that is the problem.. I
    use it every once in a while, and it doesn't break the script.
    "I’m trying to make bush button if i press it, the
    action script it well write the text in text area and I’m
    using Flash MX 2004"
    This statement makes
    zero sense.. please clean it up and make it understandable,
    and tell what version of Actionscript you are publishing to.

  • Code Doesn't work although it works on DEV

    hello evey body
    some functions and codes doesn't work on application server But it works on developer ??!!
    as i have code to export data from oracle to excell . it works from developer but it doesn't from application server
    this is my code in the link
    http://www.4shared.com/document/7wTQrK1-/Excell_Rep.html
    does Application Server didn't contain this packages ?
    or what ??

    Hi dorpfeld,
    Please check the KB : http://helpx.adobe.com/creative-suite/kb/error-serial-number-valid-product.html
    I would strongly recommend that you work directly with our support team for serial number issues.
    You can reach our chat support for serial number issues at : http://adobe.ly/1aYjbSC
    Regards,
    Rave

  • What's wrong with this simple code?

    What's wrong with this simple code? Complier points out that
    1. a '{' is expected at line6;
    2. Statement expected at the line which PI is declared;
    3. Type expected at "System.out.println("Demostrating PI");"
    However, I can't figure out them. Please help. Thanks.
    Here is the code:
    import java.util.*;
    public class DebugTwo3
    // This class demonstrates some math methods
    public static void main(String args[])
              public static final double PI = 3.14159;
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);

    Change your code to this:
    import java.util.*;
    public class DebugTwo3
         public static final double PI = 3.14159;
         public static void main(String args[])
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);
    Klint

Maybe you are looking for

  • Connect Oracle through internet

    Hi, I am trying to connect my oracle database through internet. but it is saying ORA-12203: TNS:unable to connect to destination although i tested tnsping utility, it is giving OK status. and i have also tested through telnet utility with my server s

  • Public Websites in Photos

    How do I create a Public Website out of a Shared Album in Photos? Seems like this functionality was lost from iPhoto even though it is still on Apple's Shared Albums webpage.

  • Landscape of BO

    hi all how is BO test, dev and prod environment.... how to move from dev to test?

  • Running iChat on Start Up

    I am tring to run iChat on computer startup. I've added iChat on the log in item on Accounts menu in System Preferences, but when iChat runs on startup, it doesn't log on...it just runs without connecting. How can I get iChat to automatically connect

  • Problem Running Reports on Web layout

    Hi Gurus, I am using Oracle Developer Suite 10g Release1 and I am using OS Windows XP. I created a Barcode Report and I am trying to run it via web and it is hanging. Can you please let me know y this is happening. I am using Oracle 10g DB. Thanks an