Thread: [PI] Highscores error

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 [PI] Highscores error 
    Registered Member
    Join Date
    Jun 2014
    Posts
    66
    Thanks given
    31
    Thanks received
    9
    Rep Power
    52
    So, sometimes it saves perfectly but often it gives me this error

    Code:
    [13-6-14 4:19]: [Logged in]: Iwan
    [13-6-14 4:19]: java.lang.NullPointerException
    [13-6-14 4:19]: 	at server.model.players.Highscores.destroy(Highscores.java:54)
    [13-6-14 4:19]: 	at server.model.players.Highscores.query(Highscores.java:44)
    [13-6-14 4:19]: 	at server.model.players.Highscores.save(Highscores.java:66)
    [13-6-14 4:19]: 	at server.model.players.Client.logout(Client.java:435)
    [13-6-14 4:19]: 	at server.model.players.packets.ClickingButtons.processPacket(ClickingButtons.java:1747)
    [13-6-14 4:19]: 	at server.model.players.PacketHandler.processPacket(PacketHandler.java:147)
    [13-6-14 4:19]: 	at server.model.players.Client.processQueuedPackets(Client.java:903)
    [13-6-14 4:19]: 	at server.model.players.PlayerHandler.process(PlayerHandler.java:150)
    [13-6-14 4:19]: 	at server.Server$1.execute(Server.java:224)
    [13-6-14 4:19]: 	at server.event.Task.tick(Task.java:118)
    [13-6-14 4:19]: 	at server.event.TaskScheduler.run(TaskScheduler.java:103)
    [13-6-14 4:19]: 	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    [13-6-14 4:19]: 	at java.lang.Thread.run(Unknown Source)
    [13-6-14 4:19]: java.lang.NullPointerException
    [13-6-14 4:19]: 	at server.model.players.Highscores.destroy(Highscores.java:54)
    [13-6-14 4:19]: 	at server.model.players.Highscores.query(Highscores.java:44)
    [13-6-14 4:19]: 	at server.model.players.Highscores.save(Highscores.java:68)
    [13-6-14 4:19]: 	at server.model.players.Client.logout(Client.java:435)
    [13-6-14 4:19]: 	at server.model.players.packets.ClickingButtons.processPacket(ClickingButtons.java:1747)
    [13-6-14 4:19]: 	at server.model.players.PacketHandler.processPacket(PacketHandler.java:147)
    [13-6-14 4:19]: 	at server.model.players.Client.processQueuedPackets(Client.java:903)
    [13-6-14 4:19]: 	at server.model.players.PlayerHandler.process(PlayerHandler.java:150)
    [13-6-14 4:19]: 	at server.Server$1.execute(Server.java:224)
    [13-6-14 4:19]: 	at server.event.Task.tick(Task.java:118)
    [13-6-14 4:19]: 	at server.event.TaskScheduler.run(TaskScheduler.java:103)
    [13-6-14 4:19]: 	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    [13-6-14 4:19]: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    [13-6-14 4:19]: 	at java.lang.Thread.run(Unknown Source)
    [13-6-14 4:19]: Game saved for player Iwan
    [13-6-14 4:19]: [Logged out]: Iwan
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jun 2014
    Posts
    66
    Thanks given
    31
    Thanks received
    9
    Rep Power
    52
    bump
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jun 2014
    Posts
    66
    Thanks given
    31
    Thanks received
    9
    Rep Power
    52
    bump
    Reply With Quote  
     

  4. #4  
    anInt69

    Max _'s Avatar
    Join Date
    Feb 2012
    Age
    21
    Posts
    1,824
    Thanks given
    428
    Thanks received
    721
    Rep Power
    599
    I think I know what Highscores you are using, and the error it's throwing is due to connection, as one of the conditions is
    Code:
    connection = false;
    Check you are connected correctly, if needs be have a
    Code:
    System.out.Println("connected to Highscores DB");
    if it is connected successfully.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jun 2014
    Posts
    66
    Thanks given
    31
    Thanks received
    9
    Rep Power
    52
    Yes i am correctly connected, checking that using this code

    Code:
    if (Highscores.connected) {
    			System.out
    					.println("Inferno: Highscores has been connect sucessfuly.");
    		} else {
    			System.out
    					.println("Inferno: Highscores failed connecting database.");
    		}
    This is my highscores.java
    Code:
    package server.model.players;
    
    import java.sql.*;
    
    public class Highscores {
    	public static Connection con;
    	public static Statement stm;
            public static boolean connected;
    	
    	public static String Host = "jdbc:mysql://HOST/DATABASE";
    	public static String User = "USER";
    	public static String Pass = "PASSWORD";
    	
        public static void process() {
            try
            {
                Class.forName(Driver).newInstance();
    	    Connection con = DriverManager.getConnection(Host, User, Pass);
    	    stm = con.createStatement();
                connected = true;
            }
            catch(Exception e)
            {
                connected = false;
                e.printStackTrace();
            }
        }
    
        public static ResultSet query(String s)
            throws SQLException
        {
            if(s.toLowerCase().startsWith("select"))
            {
                ResultSet resultset = stm.executeQuery(s);
                return resultset;
            }
            try
            {
                stm.executeUpdate(s);
                return null;
            }
            catch(Exception e)
            {
                destroy();
            }
            process();
            return null;
        }
    
        public static void destroy() {
            try
            {
                stm.close();
                con.close();
                connected = false;
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
    
        public static boolean save(Client c) {
            try
            {
            	query("DELETE FROM `skills` WHERE playerName = '"+c.playerName+"';");
        	    query("DELETE FROM `skillsoverall` WHERE playerName = '"+c.playerName+"';");
        	    query("INSERT INTO `skills` (`playerName`,`Attacklvl`,`Attackxp`,`Defencelvl`,`Defencexp`,`Strengthlvl`,`Strengthxp`,`Hitpointslvl`,`Hitpointsxp`,`Rangedlvl`,`Rangedxp`,`Prayerlvl`,`Prayerxp`,`Magiclvl`,`Magicxp`,`Cookinglvl`,`Cookingxp`,`Woodcuttinglvl`,`Woodcuttingxp`,`Fletchinglvl`,`Fletchingxp`,`Fishinglvl`,`Fishingxp`,`Firemakinglvl`,`Firemakingxp`,`Craftinglvl`,`Craftingxp`,`Smithinglvl`,`Smithingxp`,`Mininglvl`,`Miningxp`,`Herblorelvl`,`Herblorexp`,`Agilitylvl`,`Agilityxp`,`Thievinglvl`,`Thievingxp`,`Slayerlvl`,`Slayerxp`,`Farminglvl`,`Farmingxp`,`Runecraftlvl`,`Runecraftxp`) VALUES ('"+c.playerName+"',"+c.playerLevel[0]+","+c.playerXP[0]+","+c.playerLevel[1]+","+c.playerXP[1]+","+c.playerLevel[2]+","+c.playerXP[2]+","+c.playerLevel[3]+","+c.playerXP[3]+","+c.playerLevel[4]+","+c.playerXP[4]+","+c.playerLevel[5]+","+c.playerXP[5]+","+c.playerLevel[6]+","+c.playerXP[6]+","+c.playerLevel[7]+","+c.playerXP[7]+","+c.playerLevel[8]+","+c.playerXP[8]+","+c.playerLevel[9]+","+c.playerXP[9]+","+c.playerLevel[10]+","+c.playerXP[10]+","+c.playerLevel[11]+","+c.playerXP[11]+","+c.playerLevel[12]+","+c.playerXP[12]+","+c.playerLevel[13]+","+c.playerXP[13]+","+c.playerLevel[14]+","+c.playerXP[14]+","+c.playerLevel[15]+","+c.playerXP[15]+","+c.playerLevel[16]+","+c.playerXP[16]+","+c.playerLevel[17]+","+c.playerXP[17]+","+c.playerLevel[18]+","+c.playerXP[18]+","+c.playerLevel[19]+","+c.playerXP[19]+","+c.playerLevel[20]+","+c.playerXP[20]+");");
        	    query("INSERT INTO `skillsoverall` (`playerName`,`lvl`,`xp`) VALUES ('"+c.playerName+"',"+(c.getLevelForXP(c.playerXP[0]) + c.getLevelForXP(c.playerXP[1]) + c.getLevelForXP(c.playerXP[2]) + c.getLevelForXP(c.playerXP[3]) + c.getLevelForXP(c.playerXP[4]) + c.getLevelForXP(c.playerXP[5]) + c.getLevelForXP(c.playerXP[6]) + c.getLevelForXP(c.playerXP[7]) + c.getLevelForXP(c.playerXP[8]) + c.getLevelForXP(c.playerXP[9]) + c.getLevelForXP(c.playerXP[10]) + c.getLevelForXP(c.playerXP[11]) + c.getLevelForXP(c.playerXP[12]) + c.getLevelForXP(c.playerXP[13]) + c.getLevelForXP(c.playerXP[14]) + c.getLevelForXP(c.playerXP[15]) + c.getLevelForXP(c.playerXP[16]) + c.getLevelForXP(c.playerXP[17]) + c.getLevelForXP(c.playerXP[18]) + c.getLevelForXP(c.playerXP[19]) + c.getLevelForXP(c.playerXP[20]))+","+((c.playerXP[0]) + (c.playerXP[1]) + (c.playerXP[2]) + (c.playerXP[3]) + (c.playerXP[4]) + (c.playerXP[5]) + (c.playerXP[6]) + (c.playerXP[7]) + (c.playerXP[8]) + (c.playerXP[9]) + (c.playerXP[10]) + (c.playerXP[11]) + (c.playerXP[12]) + (c.playerXP[13]) + (c.playerXP[14]) + (c.playerXP[15]) + (c.playerXP[16]) + (c.playerXP[17]) + (c.playerXP[18]) + (c.playerXP[19]) + (c.playerXP[20]))+");");
    		}
            catch(Exception e)
            {
                e.printStackTrace();
                return false;
            }
            return true;
        }
    	public static String Driver = "com.mysql.jdbc.Driver";
    }
    Reply With Quote  
     

  6. #6  
    Member #35, most veteran member left? :D


    Join Date
    Jul 2006
    Age
    25
    Posts
    2,664
    Thanks given
    53
    Thanks received
    330
    Rep Power
    925
    Code:
    [13-6-14 4:19]: java.lang.NullPointerException
    [13-6-14 4:19]: 	at server.model.players.Highscores.destroy(Highscores.java:54)
    [13-6-14 4:19]: 	at server.model.players.Highscores.query(Highscores.java:44)
    [13-6-14 4:19]: 	at server.model.players.Highscores.save(Highscores.java:66)
    I'm going to walk you through all of the basics here, so sorry if you know some of this already. Just trying to help!

    The reason that's coming up is because you have a try/catch block somewhere that's TRYING to execute a block of code, and if it fails it will CATCH the exception and tell you what happened. Keep this in mind.

    java.lang.NullPointerException is telling you that something is null (has no value/basically nonexistent) when it shouldn't be, and that's why your exception is happening.

    at server.model.players.Highscores.destroy(Highscores .java:54) is telling you where the first major issue is happening in that chain of events you listed. This is your line 54 of Highscores.java (or at least it should be):
    Code:
    con.close();
    So, the first domino that causes that huge error is a NullPointerException happening when you attempt to close your connection. The method line 54 is found in (destroy) has that try/catch block I mentioned, which is why the error was thrown at you instead of your server crashing.

    at server.model.players.Highscores.query(Highscores.j ava:44) is saying line 44 of Highscores.java is what caused the destroy method to be executed. destroy(); is in your query method (line 44).

    at server.model.players.Highscores.save(Highscores.ja va:66) is your query method being executed on line 66 within your save method:
    Code:
    query("DELETE FROM `skills` WHERE playerName = '"+c.playerName+"';");
    The rest of the error is just more and more dominos in the whole error, showing you that the player clicked the logout button and executed the logout method (among other things), which is how all of your other highscores stuff got executed.

    So a couple of things could be the issue, and I'd check them all just to make sure. Chances are, though, that your connection is probably bad. Just because your boolean connected is true doesn't necessarily mean your server and the database are connected. If it only happens sometimes, just make sure your connection is stable and nothing is causing it to close early.

    Another thing that could be causing an issue (although I'm doubtful that it's causing THIS issue) could come from the client being removed/nullified prior to the execution of your highscores stuff (because Client c is a parameter of your save method, and the c. before playerName is saying that you're retrieving those variables from the client object). I'd focus more on your connection though.
    [Only registered and activated users can see links. ]

    `Ex-global moderator x3 (resigned)
    Reply With Quote  
     

  7. Thankful user:


  8. #7  
    Registered Member
    CTucker's Avatar
    Join Date
    Oct 2008
    Posts
    2,423
    Thanks given
    263
    Thanks received
    281
    Rep Power
    343
    If you have teamviewer, pm me your skype.
    I'll fix it.
    Reply With Quote  
     

  9. #8  
    "We donít worry about warnings; we only worry about errors."
    Rozo's Avatar
    Join Date
    Dec 2013
    Posts
    506
    Thanks given
    37
    Thanks received
    51
    Rep Power
    33
    Ardi V2? If so I can help you.
    Reply With Quote  
     

  10. #9  
    anInt69

    Max _'s Avatar
    Join Date
    Feb 2012
    Age
    21
    Posts
    1,824
    Thanks given
    428
    Thanks received
    721
    Rep Power
    599
    Quote Originally Posted by Iwan View Post
    Yes i am correctly connected, checking that using this code

    Code:
    if (Highscores.connected) {
    			System.out
    					.println("Inferno: Highscores has been connect sucessfuly.");
    		} else {
    			System.out
    					.println("Inferno: Highscores failed connecting database.");
    		}
    This is my highscores.java
    Code:
    package server.model.players;
    
    import java.sql.*;
    
    public class Highscores {
    	public static Connection con;
    	public static Statement stm;
            public static boolean connected;
    	
    	public static String Host = "jdbc:mysql://HOST/DATABASE";
    	public static String User = "USER";
    	public static String Pass = "PASSWORD";
    	
        public static void process() {
            try
            {
                Class.forName(Driver).newInstance();
    	    Connection con = DriverManager.getConnection(Host, User, Pass);
    	    stm = con.createStatement();
                connected = true;
            }
            catch(Exception e)
            {
                connected = false;
                e.printStackTrace();
            }
        }
    
        public static ResultSet query(String s)
            throws SQLException
        {
            if(s.toLowerCase().startsWith("select"))
            {
                ResultSet resultset = stm.executeQuery(s);
                return resultset;
            }
            try
            {
                stm.executeUpdate(s);
                return null;
            }
            catch(Exception e)
            {
                destroy();
            }
            process();
            return null;
        }
    
        public static void destroy() {
            try
            {
                stm.close();
                con.close();
                connected = false;
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
    
        public static boolean save(Client c) {
            try
            {
            	query("DELETE FROM `skills` WHERE playerName = '"+c.playerName+"';");
        	    query("DELETE FROM `skillsoverall` WHERE playerName = '"+c.playerName+"';");
        	    query("INSERT INTO `skills` (`playerName`,`Attacklvl`,`Attackxp`,`Defencelvl`,`Defencexp`,`Strengthlvl`,`Strengthxp`,`Hitpointslvl`,`Hitpointsxp`,`Rangedlvl`,`Rangedxp`,`Prayerlvl`,`Prayerxp`,`Magiclvl`,`Magicxp`,`Cookinglvl`,`Cookingxp`,`Woodcuttinglvl`,`Woodcuttingxp`,`Fletchinglvl`,`Fletchingxp`,`Fishinglvl`,`Fishingxp`,`Firemakinglvl`,`Firemakingxp`,`Craftinglvl`,`Craftingxp`,`Smithinglvl`,`Smithingxp`,`Mininglvl`,`Miningxp`,`Herblorelvl`,`Herblorexp`,`Agilitylvl`,`Agilityxp`,`Thievinglvl`,`Thievingxp`,`Slayerlvl`,`Slayerxp`,`Farminglvl`,`Farmingxp`,`Runecraftlvl`,`Runecraftxp`) VALUES ('"+c.playerName+"',"+c.playerLevel[0]+","+c.playerXP[0]+","+c.playerLevel[1]+","+c.playerXP[1]+","+c.playerLevel[2]+","+c.playerXP[2]+","+c.playerLevel[3]+","+c.playerXP[3]+","+c.playerLevel[4]+","+c.playerXP[4]+","+c.playerLevel[5]+","+c.playerXP[5]+","+c.playerLevel[6]+","+c.playerXP[6]+","+c.playerLevel[7]+","+c.playerXP[7]+","+c.playerLevel[8]+","+c.playerXP[8]+","+c.playerLevel[9]+","+c.playerXP[9]+","+c.playerLevel[10]+","+c.playerXP[10]+","+c.playerLevel[11]+","+c.playerXP[11]+","+c.playerLevel[12]+","+c.playerXP[12]+","+c.playerLevel[13]+","+c.playerXP[13]+","+c.playerLevel[14]+","+c.playerXP[14]+","+c.playerLevel[15]+","+c.playerXP[15]+","+c.playerLevel[16]+","+c.playerXP[16]+","+c.playerLevel[17]+","+c.playerXP[17]+","+c.playerLevel[18]+","+c.playerXP[18]+","+c.playerLevel[19]+","+c.playerXP[19]+","+c.playerLevel[20]+","+c.playerXP[20]+");");
        	    query("INSERT INTO `skillsoverall` (`playerName`,`lvl`,`xp`) VALUES ('"+c.playerName+"',"+(c.getLevelForXP(c.playerXP[0]) + c.getLevelForXP(c.playerXP[1]) + c.getLevelForXP(c.playerXP[2]) + c.getLevelForXP(c.playerXP[3]) + c.getLevelForXP(c.playerXP[4]) + c.getLevelForXP(c.playerXP[5]) + c.getLevelForXP(c.playerXP[6]) + c.getLevelForXP(c.playerXP[7]) + c.getLevelForXP(c.playerXP[8]) + c.getLevelForXP(c.playerXP[9]) + c.getLevelForXP(c.playerXP[10]) + c.getLevelForXP(c.playerXP[11]) + c.getLevelForXP(c.playerXP[12]) + c.getLevelForXP(c.playerXP[13]) + c.getLevelForXP(c.playerXP[14]) + c.getLevelForXP(c.playerXP[15]) + c.getLevelForXP(c.playerXP[16]) + c.getLevelForXP(c.playerXP[17]) + c.getLevelForXP(c.playerXP[18]) + c.getLevelForXP(c.playerXP[19]) + c.getLevelForXP(c.playerXP[20]))+","+((c.playerXP[0]) + (c.playerXP[1]) + (c.playerXP[2]) + (c.playerXP[3]) + (c.playerXP[4]) + (c.playerXP[5]) + (c.playerXP[6]) + (c.playerXP[7]) + (c.playerXP[8]) + (c.playerXP[9]) + (c.playerXP[10]) + (c.playerXP[11]) + (c.playerXP[12]) + (c.playerXP[13]) + (c.playerXP[14]) + (c.playerXP[15]) + (c.playerXP[16]) + (c.playerXP[17]) + (c.playerXP[18]) + (c.playerXP[19]) + (c.playerXP[20]))+");");
    		}
            catch(Exception e)
            {
                e.printStackTrace();
                return false;
            }
            return true;
        }
    	public static String Driver = "com.mysql.jdbc.Driver";
    }
    Did you remove the database information from the Highscores.java or did you not enter connectivity information at all?
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  11. #10  
    Registered Member
    Join Date
    Jun 2014
    Posts
    66
    Thanks given
    31
    Thanks received
    9
    Rep Power
    52
    I did remove the database info
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [pi] highscores error
    By Jupiterx in forum Help
    Replies: 4
    Last Post: 08-30-2013, 08:40 PM
  2. (pi) Highscores error but works fix for me 5$
    By garrydowling2011 in forum Buying
    Replies: 3
    Last Post: 03-05-2012, 01:23 AM
  3. [PI] Highscores Error [PI]
    By DivinescapeOwner in forum Help
    Replies: 4
    Last Post: 01-17-2012, 11:10 PM
  4. [PI] highscores error
    By Just Ice in forum Help
    Replies: 0
    Last Post: 12-10-2011, 01:12 AM
  5. [PI] Highscore Error [$20 USD]
    By Zanita in forum Help
    Replies: 4
    Last Post: 09-15-2010, 12:03 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •