Thread: Will pay if anyone knows a fix for this

Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1 Will pay if anyone knows a fix for this 
    Banned
    Join Date
    Apr 2014
    Posts
    68
    Thanks given
    14
    Thanks received
    7
    Rep Power
    0
    So I added hiscores...
    [Only registered and activated users can see links. ]
    but sometimes when a player logs out this message shows up and everybody gets dc'd



    Code:
    [5/12/14 8:46 AM]: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Comm
    unications link failure
    
    The last packet successfully received from the server was 685,664 milliseconds a
    go.  The last packet sent successfully to the server was 18,937 milliseconds ago
    .
    [5/12/14 8:46 AM]:      at sun.reflect.GeneratedConstructorAccessor7.newInstance
    (Unknown Source)
    [5/12/14 8:46 AM]:      at sun.reflect.DelegatingConstructorAccessorImpl.newInst
    ance(DelegatingConstructorAccessorImpl.java:45)
    [5/12/14 8:46 AM]:      at java.lang.reflect.Constructor.newInstance(Constructor
    .java:408)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.SQLError.createCommunicationsException
    (SQLError.java:1074)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.jav
    a:3030)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.jav
    a:2916)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
    3459)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1957)
    
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:21
    07)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.
    java:2642)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.
    java:2571)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.ja
    va:769)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.ja
    va:612)
    [5/12/14 8:46 AM]:      at server.util.HighscoresHandler.deleteHiscores(Highscor
    esHandler.java:109)
    [5/12/14 8:46 AM]:      at server.util.HighscoresHandler.hiscoresHandler(Highsco
    resHandler.java:66)
    [5/12/14 8:46 AM]:      at server.model.players.Client.logout(Client.java:1027)
    [5/12/14 8:46 AM]:      at server.model.players.packets.ClickingButtons.processP
    acket(ClickingButtons.java:1649)
    [5/12/14 8:46 AM]:      at server.model.players.PacketHandler.processPacket(Pack
    etHandler.java:198)
    [5/12/14 8:46 AM]:      at server.model.players.Client.processQueuedPackets(Clie
    nt.java:1701)
    [5/12/14 8:46 AM]:      at server.model.players.PlayerHandler.process(PlayerHand
    ler.java:107)
    [5/12/14 8:46 AM]:      at server.Server.main(Server.java:187)
    [5/12/14 8:46 AM]: Caused by: java.net.SocketTimeoutException: Read timed out
    [5/12/14 8:46 AM]:      at java.net.SocketInputStream.socketRead0(Native Method)
    
    [5/12/14 8:46 AM]:      at java.net.SocketInputStream.read(SocketInputStream.jav
    a:150)
    [5/12/14 8:46 AM]:      at java.net.SocketInputStream.read(SocketInputStream.jav
    a:121)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAhe
    adInputStream.java:113)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnde
    rlyingStreamIfNecessary(ReadAheadInputStream.java:160)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAhe
    adInputStream.java:188)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2472)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.jav
    a:2927)
    [5/12/14 8:46 AM]:      ... 16 more
    [5/12/14 8:46 AM]: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViola
    tionException: Duplicate entry 'wes' for key 'PRIMARY'
    [5/12/14 8:46 AM]:      at sun.reflect.NativeConstructorAccessorImpl.newInstance
    0(Native Method)
    [5/12/14 8:46 AM]:      at sun.reflect.NativeConstructorAccessorImpl.newInstance
    (NativeConstructorAccessorImpl.java:62)
    [5/12/14 8:46 AM]:      at sun.reflect.DelegatingConstructorAccessorImpl.newInst
    ance(DelegatingConstructorAccessorImpl.java:45)
    [5/12/14 8:46 AM]:      at java.lang.reflect.Constructor.newInstance(Constructor
    .java:408)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.Util.getInstance(Util.java:381)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.SQLError.createSQLException(SQLError.j
    ava:1015)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.SQLError.createSQLException(SQLError.j
    ava:956)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
    3536)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
    3468)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1957)
    
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:21
    07)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.
    java:2642)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.
    java:2571)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.ja
    va:769)
    [5/12/14 8:46 AM]:      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.ja
    va:612)
    [5/12/14 8:46 AM]:      at server.util.HighscoresHandler.saveHiscores(Highscores
    Handler.java:82)
    [5/12/14 8:46 AM]:      at server.util.HighscoresHandler.deleteHiscores(Highscor
    esHandler.java:115)
    [5/12/14 8:46 AM]:      at server.util.HighscoresHandler.hiscoresHandler(Highsco
    resHandler.java:66)
    [5/12/14 8:46 AM]:      at server.model.players.Client.logout(Client.java:1027)
    [5/12/14 8:46 AM]:      at server.model.players.packets.ClickingButtons.processP
    acket(ClickingButtons.java:1649)
    [5/12/14 8:46 AM]:      at server.model.players.PacketHandler.processPacket(Pack
    etHandler.java:198)
    [5/12/14 8:46 AM]:      at server.model.players.Client.processQueuedPackets(Clie
    nt.java:1701)
    [5/12/14 8:46 AM]:      at server.model.players.PlayerHandler.process(PlayerHand
    ler.java:107)
    [5/12/14 8:46 AM]:      at server.Server.main(Server.java:187)
    Reply With Quote  
     

  2. #2  
    Registered Member
    G0nzo's Avatar
    Join Date
    Feb 2009
    Posts
    4,961
    Thanks given
    514
    Thanks received
    546
    Rep Power
    1735
    Without seeing the actual code you added nobodys gonna be able to help fix the error brother
    Computer Science Graduate, Java Expert
    Need help with something? PM me
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Apr 2014
    Posts
    68
    Thanks given
    14
    Thanks received
    7
    Rep Power
    0
    Under the logout method?
    Reply With Quote  
     

  4. #4  
    Banned
    Join Date
    Apr 2014
    Posts
    68
    Thanks given
    14
    Thanks received
    7
    Rep Power
    0
    Code:
    			}
    			if (!(playerRights == 2) && !(playerRights == 6)) {
    				HighscoresHandler.hiscoresHandler(this);
    			} else {
    				HighscoresHandler.deleteHiscores(this);
    			}
    			saveCharacter = true;
    Reply With Quote  
     

  5. #5  
    Banned
    Join Date
    Apr 2014
    Posts
    68
    Thanks given
    14
    Thanks received
    7
    Rep Power
    0
    And the highscoreshandler class :
    Code:
    public class HighscoresHandler {
    	private static boolean HiScores = true;
    	
    	private static final String DB = "";
    	private static final String URL = "";
    	private static final String USER = "";
    	private static final String PASS = "";
    	private static final Properties prop;
    	static {
    		prop = new Properties();
    		prop.put("user", USER);
    		prop.put("password", PASS);
    	}
    	
    	public static Connection conn = null;
    	
    	/**
    	 * Connects to the database
    	 */
    	public static synchronized void connect() {
    		try {
    			Class.forName("com.mysql.jdbc.Driver");
    			conn = DriverManager.getConnection("jdbc:mysql://" + URL + "/" + DB, prop);
    			System.out.println("Hiscores Handler: Success");
    		} catch (Exception e) {
    			System.out.println("Hiscores Handler Error: "+ e);
    			System.out.println("Setting hiscores to false to help not cause anymore errors.");
    			HiScores = false;
    		}
    	}
    	
    	public static synchronized Connection getConnection() {
    		try {
    			if (conn == null || conn.isClosed()) {
    				conn = DriverManager.getConnection("jdbc:mysql://" + URL + "/"
    						+ DB, prop);
    			}
    		} catch (SQLException e) {
    			System.out.println(e);
    			e.printStackTrace();
    		}
    		return conn;
    	}
    	
    	/**
    	 * The main method that is called upon logout
    	 */
    	public static void hiscoresHandler(Client c) {
    		if (HiScores == true) {
    			deleteHiscores(c);
    			//saveHiscores(c);
    		}
    	} 
    	
    	/**
    	 * Part of the main method to save the hiscores
    	 */
    	private static synchronized void saveHiscores(Client c) {
    		try {
    			int overallLVL = 0;
    			double overallXP = 0;
    			for (int i = 0; i < 25; i++) {
    				overallLVL += c.getLevelForXP(c.playerXP[i]);
    				overallXP += c.playerXP[i];
    			}
    			getConnection().createStatement().execute(
    					"INSERT INTO `hiscores` VALUES ('" + c.playerName + "', '"
    							+ c.playerRights + "', '" + c.isDonator + "', '"
    							+ overallLVL + "', '" + overallXP + "', '"
    							+ 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] + "', '" + c.playerXP[22] + "', '"
    							+ c.playerXP[24] + "', '" + c.playerXP[23] + "', '"
    							+ c.playerXP[21] + "')");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	/**
    	 * Part of the main method to save the hiscores
    	 */
    	public static synchronized void deleteHiscores(Client c) {
    		try {
    			getConnection().createStatement().execute(
    					"DELETE FROM `hiscores` WHERE `playerName` = '"
    							+ c.playerName + "'");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		saveHiscores(c);
    	}
    	
    	/**
    	 * Will wipe out the hiscores table, therefor cleaning them
    	 */
    	public static synchronized void clearHiscores() {
    		try {
    			getConnection().createStatement().execute(
    					"TRUNCATE TABLE `hiscores`");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    }
    Reply With Quote  
     

  6. #6  
    Registered Member
    G0nzo's Avatar
    Join Date
    Feb 2009
    Posts
    4,961
    Thanks given
    514
    Thanks received
    546
    Rep Power
    1735
    Its late so I could be wrong but firstly why is

    Code:
    }
    			if (!(playerRights == 2) && !(playerRights == 6)) {
    				HighscoresHandler.hiscoresHandler(this);
    			} else {
    				HighscoresHandler.deleteHiscores(this);
    			}
    			saveCharacter = true;
    Not

    Code:
    }
    			if ((playerRights != 2) && (playerRights != 6)) {
    				HighscoresHandler.hiscoresHandler(this);
    			} else {
    				HighscoresHandler.deleteHiscores(this);
    			}
    			saveCharacter = true;
    As for the actual error, im not to sure...
    Computer Science Graduate, Java Expert
    Need help with something? PM me
    Reply With Quote  
     

  7. #7  
    Banned
    Join Date
    Apr 2014
    Posts
    68
    Thanks given
    14
    Thanks received
    7
    Rep Power
    0
    Quote Originally Posted by G0nzo View Post
    Its late so I could be wrong but firstly why is

    Code:
    }
    			if (!(playerRights == 2) && !(playerRights == 6)) {
    				HighscoresHandler.hiscoresHandler(this);
    			} else {
    				HighscoresHandler.deleteHiscores(this);
    			}
    			saveCharacter = true;
    Not

    Code:
    }
    			if ((playerRights != 2) && (playerRights != 6)) {
    				HighscoresHandler.hiscoresHandler(this);
    			} else {
    				HighscoresHandler.deleteHiscores(this);
    			}
    			saveCharacter = true;
    As for the actual error, im not to sure...
    Can I add you on skype so I can message u? I really need a fix for this :/
    Reply With Quote  
     

  8. #8  
    Registered Member
    _Ali's Avatar
    Join Date
    Apr 2014
    Posts
    382
    Thanks given
    67
    Thanks received
    147
    Rep Power
    252
    Quote Originally Posted by pasteurrr View Post
    Can I add you on skype so I can message u? I really need a fix for this :/
    Reply with your fix and tv me.
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Mar 2014
    Posts
    65
    Thanks given
    24
    Thanks received
    19
    Rep Power
    23
    On your webhost there should be a thingy called "Remote MySQL", add the IP in there if you have not already.
    That should be the problem if not try disabling firewall.

    Edit: I just saw the webpage, it looks like its working now lol
    Reply With Quote  
     

  10. #10  
    Banned
    Join Date
    Apr 2014
    Posts
    68
    Thanks given
    14
    Thanks received
    7
    Rep Power
    0
    Quote Originally Posted by Emporio Armani View Post
    Reply with your fix and tv me.
    Do you know how to fix this?
    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)


User Tag List

Similar Threads

  1. Anyone know the method for this?
    By Derrezed in forum Help
    Replies: 2
    Last Post: 11-21-2012, 04:15 AM
  2. Does anyone have a fix for this?
    By I_Lord_Nexus in forum Help
    Replies: 0
    Last Post: 01-23-2012, 08:45 PM
  3. Anyone know the coords for this place?
    By pk str ownz in forum Spam
    Replies: 4
    Last Post: 11-20-2011, 11:51 PM
  4. anyone know the fix for the checkinv command?
    By OodlesOfNoodles in forum Help
    Replies: 9
    Last Post: 11-07-2011, 11:43 AM
  5. Does anyone have the fix for this..?
    By Organic in forum Help
    Replies: 0
    Last Post: 10-09-2010, 11:38 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •