Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

jdbc and database question, need help

bengesbenges Member Posts: 331
why isn't the statement.executeQuery(...) return boolean value to true since it found true? where i search the documentation saying it would?

because i have tested it for many time for the record that can found in the database, but it just won't return the boolean to false if the record is not found! please guide, thanks

thank for everyone, please really help in here

Comments

  • IllcoIllco Member Posts: 382
    : why isn't the statement.executeQuery(...) return boolean value to true since it found true? where i search the documentation saying it would?
    :
    : because i have tested it for many time for the record that can found in the database, but it just won't return the boolean to false if the record is not found! please guide, thanks
    :
    : thank for everyone, please really help in here
    :

    Documentation on any default Java method can be found in the Application Programmer Interface (API for short). This can be found at the sun website and any serious Java programmer uses it frequently. About your problem I found only the following (method of class Statement):

    [b]ResultSet executeQuery(String sql)[/b]
    [i]Executes the given SQL statement, which returns a single ResultSet object.[/i]

    So I didn't find a function returning a boolean anyhow - which class is this method in?
  • bengesbenges Member Posts: 331
    : : why isn't the statement.executeQuery(...) return boolean value to true since it found true? where i search the documentation saying it would?
    : :
    : : because i have tested it for many time for the record that can found in the database, but it just won't return the boolean to false if the record is not found! please guide, thanks
    : :
    : : thank for everyone, please really help in here
    : :
    :
    : Documentation on any default Java method can be found in the Application Programmer Interface (API for short). This can be found at the sun website and any serious Java programmer uses it frequently. About your problem I found only the following (method of class Statement):
    :
    : [b]ResultSet executeQuery(String sql)[/b]
    : [i]Executes the given SQL statement, which returns a single ResultSet object.[/i]
    :
    : So I didn't find a function returning a boolean anyhow - which class is this method in?
    :
    i have confirm on using the solution u gave, but it just won't return the expected result, y?
    let me show u my coding:
    [b]
    c.nativeSQL(str1);
    s = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    boolean f = s.execute(str1);

    if(f==true)
    JOptionPane.showMessageDialog(null, "No Such Book Record! Please check!", "Not Found!", JOptionPane.ERROR_MESSAGE);
    else{
    c.nativeSQL(str);
    s1 = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    s1.execute(str);
    JOptionPane.showMessageDialog(null, "Book is Borrowed!", "Book OUT!", JOptionPane.INFORMATION_MESSAGE);
    }
    s.close();
    [/b]

    why is this happen?
  • IllcoIllco Member Posts: 382
    I don't know your problem very well. Therefore I didn't provide a solution but just pointed you at the documentation. Second, you're first function question was about [b]executeQuery[/b], now I see you meant [b]execute[/b]. This is what the doc says about:

    [code]
    Returns:
    true if the first result is a ResultSet object; false if it is an update count or there are no results
    [/code]
  • bengesbenges Member Posts: 331
    : : : why isn't the statement.executeQuery(...) return boolean value to true since it found true? where i search the documentation saying it would?
    : : :
    : : : because i have tested it for many time for the record that can found in the database, but it just won't return the boolean to false if the record is not found! please guide, thanks
    : : :
    : : : thank for everyone, please really help in here
    : : :
    : :
    : : Documentation on any default Java method can be found in the Application Programmer Interface (API for short). This can be found at the sun website and any serious Java programmer uses it frequently. About your problem I found only the following (method of class Statement):
    : :
    : : [b]ResultSet executeQuery(String sql)[/b]
    : : [i]Executes the given SQL statement, which returns a single ResultSet object.[/i]
    : :
    : : So I didn't find a function returning a boolean anyhow - which class is this method in?
    : :
    : i have confirm on using the solution u gave, but it just won't return the expected result, y?
    : let me show u my coding:
    : [b]
    : c.nativeSQL(str1);
    : s = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    : boolean f = s.execute(str1);
    :
    : if(f==true)
    : JOptionPane.showMessageDialog(null, "No Such Book Record! Please check!", "Not Found!", JOptionPane.ERROR_MESSAGE);
    : else{
    : c.nativeSQL(str);
    : s1 = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    : s1.execute(str);
    : JOptionPane.showMessageDialog(null, "Book is Borrowed!", "Book OUT!", JOptionPane.INFORMATION_MESSAGE);
    : }
    : s.close();
    : [/b]
    :
    : why is this happen?
    :
    i'll try it guy, thx a lot.
    if i encounter error, can i just ask for it again? thx again
  • Andre YoungAndre Young USAMember Posts: 0

    _____ // http://forcoder.org // free video tutorials and ebooks about || MATLAB Scratch Swift PL/SQL PHP Perl C# Go Visual Basic .NET Delphi JavaScript R Visual Basic Java Ruby Python C Objective-C C++ Assembly Transact-SQL Kotlin FoxPro Logo Alice Lua ML Ada F# Clojure COBOL D Hack Awk LabVIEW Erlang Rust Scheme Dart Crystal SAS Fortran ABAP Scala Bash Prolog Lisp Apex VBScript Julia || __

Sign In or Register to comment.