Thread: Why is this happening to me?!

Results 1 to 6 of 6
  1. #1 Why is this happening to me?! 
    Registered Member Mouldy's Avatar
    Join Date
    Oct 2012
    Posts
    91
    Thanks given
    3
    Thanks received
    3
    Rep Power
    50


    Yeah..

    Problems..

    The server doesn't like to save characters, it also likes to corrupt them and keep them logged in.
    The server commands don't like working, I mean.. ::yell works but otherwise none of them do.

    Please help? :/
    Reply With Quote  
     

  2. #2  
    Community Veteran

    Songoty's Avatar
    Join Date
    Dec 2007
    Posts
    2,740
    Thanks given
    211
    Thanks received
    1,034
    Rep Power
    2455
    Well lets start by having you post some code snippets from PlayersOnline (Line 32). Please do not just post the single line, include the whole method.
    Reply With Quote  
     

  3. #3  
    Registered Member Mouldy's Avatar
    Join Date
    Oct 2012
    Posts
    91
    Thanks given
    3
    Thanks received
    3
    Rep Power
    50
    Quote Originally Posted by Songoty View Post
    Well lets start by having you post some code snippets from PlayersOnline (Line 32). Please do not just post the single line, include the whole method.
    I have no idea what that means.. I am not the server coder for my server
    Reply With Quote  
     

  4. #4  
    Community Veteran

    Songoty's Avatar
    Join Date
    Dec 2007
    Posts
    2,740
    Thanks given
    211
    Thanks received
    1,034
    Rep Power
    2455
    Open PlayersOnline.java, located in src/server/util/

    Copy the whole file

    Paste it into the reply box in between code tags
    Reply With Quote  
     

  5. #5  
    Registered Member Mouldy's Avatar
    Join Date
    Oct 2012
    Posts
    91
    Thanks given
    3
    Thanks received
    3
    Rep Power
    50
    Code:
    package server.util;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    import server.model.players.Client;
    import server.model.players.PlayerHandler;
    
    public class PlayersOnline {
    
    	public static Connection con = null;
    	public static Statement stm;
    
    	public static void createCon() {
    		try {
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    			con = DriverManager.getConnection("", "", "");
    			stm = con.createStatement();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    	public static ResultSet query(String s) throws SQLException {
    		try {
    			if (s.toLowerCase().startsWith("select")) {
    				ResultSet rs = stm.executeQuery(s);
    				return rs;
    			} else {
    				stm.executeUpdate(s);
    			}
    			return null;
    		} catch (Exception e) {
    			Misc.println("MySQL Error:"+s);
    			e.printStackTrace();
    		}
    		return null;
    	}
    
    	public static void destroyCon() {
    		try {
    			stm.close();
    			con.close();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}	
    
    	public static boolean offline(Client c) {
    		try {
    			query("DELETE FROM `online` WHERE id = 1;");
    
    		} catch (Exception e) {
    			e.printStackTrace();
    			return false;
    		}
    		return true;
    	}
    
    	public static boolean online(Client c) {
    		try {
    			query("INSERT INTO `online` (id, currentlyonline) VALUES('1','"+PlayerHandler.getPlayerCount()+"');");
    
    		} catch (Exception e) {
    			e.printStackTrace();
    			return false;
    		}
    		return true;
    	}
    }
    Reply With Quote  
     

  6. #6  
    Community Veteran

    Songoty's Avatar
    Join Date
    Dec 2007
    Posts
    2,740
    Thanks given
    211
    Thanks received
    1,034
    Rep Power
    2455
    is your sql connection valid on the query
    Reply With Quote  
     


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. Is This Happening To Everyone, Or Just Me?
    By Gluon in forum Complaints
    Replies: 17
    Last Post: 10-03-2012, 02:25 AM
  2. Why is This Happening
    By addicted in forum Help
    Replies: 3
    Last Post: 07-18-2010, 05:06 AM
  3. Why is this happening?
    By 'Exs Faith in forum Help
    Replies: 7
    Last Post: 04-14-2010, 09:35 PM
  4. Why is this happening?
    By BenjaR in forum Help
    Replies: 7
    Last Post: 10-23-2009, 02:58 AM
  5. Replies: 6
    Last Post: 10-22-2009, 07:24 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
  •