MySQL nullpointer.

Discussion in 'Plugin Development' started by wouter0100, Dec 22, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    wouter0100

    Hey,

    I'm using this:
    Code:
    		ResultSet ipfilter = null;
    		ipfilter = MySQL.query("SELECT * FROM leden WHERE naam = '" + naam + "' AND ip_filter != '' LIMIT 1");
        	if(ipfilter != null)
        	{
    	    	try {
    				String[] ip_list = ipfilter.getString("ip_filter").split(",");
    				boolean Check = true;
    				for(String ipuser : ip_list)
    				{
    					if(ip.equals("/" + ipuser))
    					{
    						Check = false;
    					}
    				}
    				if(Check)
    				{
    					player.kickPlayer("Inloggen op een beveiligd account met een niet voorkomend IP.");
    		    		log.warning(naam + " op het IP " + ip + " fout ingelogd!");
    				}
    			} catch (SQLException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
        	}
    
    for my OnPlayerJoin event, this is an simple IPcheck.
    But it dont work.
    In the database ("ip_filter") are there ip's (not for every player, they can set them.) stored, all ip's are listed with a , between them.
    [ip 1],[ip 2]
    etc, but it can be 1 ip, 0 ip's, and 100 ips.
    But i got an nullpointer on the query line.
    btw. naam = name and i'm sure that the name variable is the user's name.
    leden = users

    (Dutch :$)

    Thanks!

     
  2. Offline

    Lolmewn

    What's line 106?
     
  3. Offline

    wouter0100

    Yea, sorry, line 106 is the query line,
     
  4. Offline

    unicode21B9

    The only way I can think of a null pointer exception being caused directly by this line:
    Code:
    ipfilter = MySQL.query("SELECT * FROM leden WHERE naam = '" + naam + "' AND ip_filter != '' LIMIT 1");
    is if MySQL is a variable which is null at this point.
     
  5. Offline

    wouter0100

    It isn't, I'm doing before this query other query's, they succes.
    But i have tried somethings others, hopefull this works.
    (Waiting on my players when they leave xd, too full for a restart.)
     
Thread Status:
Not open for further replies.

Share This Page