Search code examples
javamysqljdbccorbaidl

Java:Error on implementing a method from supertype


I am working on a college project java MemoryCatcherServant.java and I am getting this error:

method does not override or implement a method from a supertype

Does anyone have a fix? Any help would certainly be appreciated. Quick and precise answer will certainly be rewarded :)

@Override
public boolean purchaseMemoryPoints(int memoryPointAmount, int userId) {
    String error;
    Connection connection;
    Statement stmt = null;
    Statement stmt2 = null;
    int memoryPoints = 0;

    try {

        connection = DriverManager
        .getConnection("jdbc:mysql://localhost/memorycatcher","root", "root");


    } catch (SQLException e) {
        return false;
    }

    if (connection != null) {


        //make connection
        try {
            stmt = connection.createStatement();
            String sql = "SELECT userMemoryPoints FROM users WHERE userId = \""+userId+"\"";
            ResultSet rs = stmt.executeQuery(sql);

            while(rs.next())
            {

                memoryPoints = rs.getInt("userMemoryPoints");
            }

            rs.close();
            stmt.close();

            int newMemoryPoints = memoryPoints + memoryPointAmount;

            stmt2 = connection.createStatement();
            String sql2 = "UPDATE users SET userMemoryPoints = newMemoryPoints WHERE userId = \""+userId+"\"";

            stmt2.close();
            connection.close();

            return true;
        } catch (SQLException e) {
            //error handling
            return false;
        }

    } else {
        return false;
    }
}

The IDL for the memorycatcher purchase

//user enters the amount of points they want to purchase
boolean purchaseMemoryPoints(in long memoryPointAmount, in long userId);

Solution

  • Try removing the @Override annotation (first line) for a start.

    If you are sure that the method does override another method, though, your compiler might be set to an ancient Java version (the @Override-annotation was not allowed in interfaces before Java 1.6).