i am using an else if to call a method from another class but it says a ')' is expected can anyone help please :D

else if (source == tol.jbTakeOut)
       {    bookname = tol.jtfBookName.getText();
           authorf = tol.jtfAuthorFName.getText();
           authors = tol.jtfAuthorSName.getText();
           [I]Store.changeLoanStatus(String bookname, String authorf, String authors);[/I] //the line which the error appears on :\
           Storage.closeConnection();
        }

the class being called :D

public void changeLoanStatus(String bookname, String authorf, String authors) 
{
if (takenOut = false) takenOut = true;
if (takenOut = true)  takenOut = false;

    String sql="UPDATE tblBook SET TakenOut = '" + takenOut + "'  WHERE BookName = '" + bookname + "' AND Firstname = '" + authorf + "' AND Surname = '" + authors + "'";
    System.out.println("Sql statement : " + sql);   
     try 
     {
        int ok;
        statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);  
        ok=statement.executeUpdate(sql);
        connection.commit();
        System.out.println("LoanStatus Changed");
     }
     catch (Exception e) 
     {
        System.out.println("Unable to take on Loan " + e.getMessage() );
     }           
}

thanks for the help in advance

Recommended Answers

All 5 Replies

Is that the exact line? The arguments obviously need no data type. What's the name of the class that method belongs to?

It looks as if your calling a non-static method statically. So you want to either make an instance reference and call your method that way or make the method static.

You don't include the parameter types in a method call. Remove them and only pass the variables by themselves:

Store.changeLoanStatus(bookname, authorf, authors);

Then on the same line "Store.changeLoanStatus(bookname, authorf, authors); a new error has appeared - - - - "non-static method changeLoanStatus(java.lang.String,java.lang.String,java.lang.String) cannot be referenced from a static context ? :S ?

See blackcompe's response above.

cheeeeeeeersss people
but thats the least of my problems now....
the message says ...

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:

and lists a loads of things :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.