0

I have a quick question.

I have this method here which says that the variable "worker" is not being used. What kind of syntax would I write below it in order to run it? I have printed a system.out line and it is not running.

        SQLWorker worker = new SQLWorker(SQLEngine.UPDATE_HIGH_SCORES) {
        @Override
        public ResultSet executeSQL(Connection c, PreparedStatement st)
                throws SQLException {
            System.out.println("part 2");
            return null;
        }
    };

As well as the method not running, Eclipse also says "worker" isn't being used.

3
  • Who is calling the method ? Commented Oct 28, 2013 at 16:55
  • 1
    On a completely unrelated note, cough hibernate cough. It makes this kind of thing sooooo much sweeter =) Commented Oct 28, 2013 at 16:56
  • This is not a method. This is a variable declaration and initializaion. And the variable is initialized wih a new instance of an anonymous class which extends SQLWorker and overrides one of its methods. If you don't use the variable worker later in the code, then this doesn't do anything (other than the potential side-effects of the SQLWorker constructor) Commented Oct 28, 2013 at 16:57

3 Answers 3

1

Here, you are only defining the worker. In order to run something do : e.g. worker.executeSQL(...)

Sign up to request clarification or add additional context in comments.

Comments

0

Write worker. below your snippet, and press CTRL+SPACE. You should see API suggestions, and you will find your "run" method there (can be something like run(), execute(), doQuery() etc. - read the javadoc).

Comments

0

What do you want to archive? I ask this because i assume you dont want to use that google classes :)

The warning:

Thats because you crate a object worker but seem to never use it afterwards. Call worker.executeSQL (the method you overriden) or any other method you gained there.

The Problem:

I dont use those google classes so i dont know what the SQLWorker is used for, your source however seems to be correct... but i doubt its useful for what you try to archive ;)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.