MySQL stats Plugin

Discussion in 'Plugin Development' started by DaveLillo, Mar 29, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    DaveLillo

    Hello community,

    I'm currently working on a stats plugin. All functions are workung, but one isn't. I want to implement, that the top 10 players with the most kills can be viewed with a command. But i always get an error with this:

    Code:
    @SuppressWarnings("deprecation")
        public void berechneTopList(){
    
            this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
    
                @Override
                public void run() {
    
                    System.out.println("Starte mit dem Berechnen der Toplist!");
                    int x = 0;
                       
                    String q = "SELECT COUNT (*) FROM stats";
    
                    try {
                        ResultSet rs4 = s.executeQuery(q);
                        rs4.next();
                        x = rs4.getInt(1);
                        rs4.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
    And thats the error:

    Code:
    [15:30:05 INFO]: Starte mit dem Berechnen der Toplist!
    [15:30:05 WARN]: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You
    have an error in your SQL syntax; check the manual that corresponds to your MySQ
    L server version for the right syntax to use near '*) FROM stats' at line 1
    [15:30:05 WARN]:        at sun.reflect.GeneratedConstructorAccessor13.newInstanc
    e(Unknown Source)
    [15:30:05 WARN]:        at sun.reflect.DelegatingConstructorAccessorImpl.newInst
    ance(Unknown Source)
    [15:30:05 WARN]:        at java.lang.reflect.Constructor.newInstance(Unknown Sou
    rce)
    [15:30:05 WARN]:        at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    [15:30:05 WARN]:        at com.mysql.jdbc.Util.getInstance(Util.java:382)
    [15:30:05 WARN]:        at com.mysql.jdbc.SQLError.createSQLException(SQLError.j
    ava:1052)
    [15:30:05 WARN]:        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
    3593)
    [15:30:05 WARN]:        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
    3525)
    [15:30:05 WARN]:        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
    
    [15:30:05 WARN]:        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:21
    40)
    [15:30:05 WARN]:        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.
    java:2620)
    [15:30:05 WARN]:        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.
    java:2570)
    [15:30:05 WARN]:        at com.mysql.jdbc.StatementImpl.executeQuery(StatementIm
    pl.java:1474)
    [15:30:05 WARN]:        at me.DaveLillo.stats.Main$2.run(Main.java:288)
    [15:30:05 WARN]:        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.ru
    n(CraftTask.java:71)
    [15:30:05 WARN]:        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftAsyncTa
    sk.run(CraftAsyncTask.java:53)
    [15:30:05 WARN]:        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unk
    nown Source)
    [15:30:05 WARN]:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Un
    known Source)
    [15:30:05 WARN]:        at java.lang.Thread.run(Unknown Source)
    [15:30:05 INFO]: 0
    [15:30:05 INFO]: Berechnen der Toplist beendet!
    Whats the problem?

    PS: In line 288 is:

    Code:
    ResultSet rs4 = s.executeQuery(q);
    Dave
     
  2. Offline

    uksspy

    @DaveLillo
    I am pretty nooby at MySQL myself, but I do
    know that the error says this \/
    Code:
    "SELECT COUNT (*) FROM stats"
    query syntax is incorrect. So just make sure you are using the correct syntax.

    Code:
    You
    have an error in your SQL syntax; check the manual that corresponds to your MySQ
    L server version for the right syntax to use near '*) FROM stats' at line 1
     
  3. Offline

    DaveLillo

    @uksspy I googled the syntax and found it on many sites like that...
    Maybe its not implemented in Java 7? I'm using Java 7

    Dave
     
  4. Offline

    RainoBoy97

    Remove the space between COUNT and (*) :)
     
    DaveLillo likes this.
  5. Offline

    DaveLillo

Thread Status:
Not open for further replies.

Share This Page