Thread: mysql/highscores =o

Results 1 to 6 of 6
  1. #1 mysql/highscores =o 
    Registered Member
    Sieu's Avatar
    Join Date
    Dec 2011
    Age
    30
    Posts
    1,167
    Thanks given
    186
    Thanks received
    131
    Rep Power
    160
    Code:
    [8/10/12 11:08 PM]: Hiscores Handler Error: java.sql.SQLException: Must specify
    port after ':' in connection string
    I get that error where would I add the port? I don't see any ':'

    here's my highscores class where I get the error

    Code:
    package server.util;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.Properties;
    
    import server.model.players.Client;
    
    /**
     * 
     * @author Joshua F
     * @author PJNoMore
     *
     */
    
    public class HiscoresHandler {
    	private static boolean HiScores = true;
    
    	private static final String DB = "db";
    	private static final String URL = "google.com";
    	private static final String USER = "mmmm";
    	private static final String PASS = "zzz";
    	private static final Properties prop;
    	static {
    		prop = new Properties();
    		prop.put("user", USER);
    		prop.put("password", PASS);
    		//prop.put("autoReconnect", "true");
    		//prop.put("maxReconnects", "4");
    	}
    	
    	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 < 21; 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] + "')");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	/**
    	 * Part of the main method to save the hiscores
    	 */
    	private static synchronized void deleteHiscores(Client c) {
    		try {
    			getConnection().createStatement().execute(
    					"DELETE FROM `hiscores` WHERE `playerName` = '"
    							+ c.playerName + "'");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    	
    	/**
    	 * 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  
     

  2. #2  
    Registered Member
    Freezia's Avatar
    Join Date
    Feb 2011
    Posts
    6,013
    Thanks given
    1,147
    Thanks received
    758
    Rep Power
    1311
    private static final String URL = "google.com:3306";

    Just add :3306 after the domain name...


    Host your RUNESCAPE PRIVATE SERVER on the cheapest and flagship provider on Rune-Server! Now equipped with DDOS Protection!.


    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Sieu's Avatar
    Join Date
    Dec 2011
    Age
    30
    Posts
    1,167
    Thanks given
    186
    Thanks received
    131
    Rep Power
    160
    still doesn't work, maybe it's because I have more than 1 database?
    Reply With Quote  
     

  5. #4  
    Registered Member
    Freezia's Avatar
    Join Date
    Feb 2011
    Posts
    6,013
    Thanks given
    1,147
    Thanks received
    758
    Rep Power
    1311
    More then one database? That has nothing too do with it... just enter in the database details into the locations where it asks for them and it should work... what tutorial are you doing?


    Host your RUNESCAPE PRIVATE SERVER on the cheapest and flagship provider on Rune-Server! Now equipped with DDOS Protection!.


    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Registered Member
    Sieu's Avatar
    Join Date
    Dec 2011
    Age
    30
    Posts
    1,167
    Thanks given
    186
    Thanks received
    131
    Rep Power
    160
    http://www.rune-server.org/runescape...-hiscores.html

    this one I believe I don't know anything about Mysql/Php lol.
    Reply With Quote  
     

  8. #6  
    Registered Member
    Freezia's Avatar
    Join Date
    Feb 2011
    Posts
    6,013
    Thanks given
    1,147
    Thanks received
    758
    Rep Power
    1311
    Quote Originally Posted by MMMM View Post
    http://www.rune-server.org/runescape...-hiscores.html

    this one I believe I don't know anything about Mysql/Php lol.
    Okay, speak to your webhost they will surely help you out.


    Host your RUNESCAPE PRIVATE SERVER on the cheapest and flagship provider on Rune-Server! Now equipped with DDOS Protection!.


    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. Help with MySQL highscores
    By Sabbath in forum Help
    Replies: 1
    Last Post: 11-04-2011, 08:34 AM
  2. MySQL highscores error
    By Escaped in forum Application Development
    Replies: 10
    Last Post: 06-19-2010, 01:39 AM
  3. Mysql Server (highscores to)
    By pkin3 in forum Downloads
    Replies: 25
    Last Post: 03-27-2009, 07:06 PM
  4. Mysql.php from t x's highscores
    By Ayton in forum Requests
    Replies: 2
    Last Post: 11-25-2008, 05:04 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
  •