Without seeing the actual code you added nobodys gonna be able to help fix the error brother
|
|
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)
Without seeing the actual code you added nobodys gonna be able to help fix the error brother
Under the logout method?
Code:} if (!(playerRights == 2) && !(playerRights == 6)) { HighscoresHandler.hiscoresHandler(this); } else { HighscoresHandler.deleteHiscores(this); } saveCharacter = true;
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(); } } }
Its late so I could be wrong but firstly why is
NotCode:} if (!(playerRights == 2) && !(playerRights == 6)) { HighscoresHandler.hiscoresHandler(this); } else { HighscoresHandler.deleteHiscores(this); } saveCharacter = true;
As for the actual error, im not to sure...Code:} if ((playerRights != 2) && (playerRights != 6)) { HighscoresHandler.hiscoresHandler(this); } else { HighscoresHandler.deleteHiscores(this); } saveCharacter = true;
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
| « Will pay if anyone knows a fix for this | Website » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |