jdbc and database question, need help

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

  • : 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?
  • : : 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 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]
  • : : : 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
Sign In or Register to comment.

Howdy, Stranger!

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

Categories