Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Creative commons Attribution-NonCommercial license. http://creativecommons.org/licenses/by-nc/2.5/au/deed.en_GB NO WARRANTY IS GIVEN OR IMPLIED, USE AT YOUR OWN RISK.
 
 package base.jee.api.sql;
 
import base.Query;
import static base.jee.api.sql.util.IpLocation.ipLocation;
import static base.jee.Constants.MAX_IP_ADDRESS_LENGTH;
public class GetLocationByIP extends Query<Location> {
	private SqlAPI api;
	private String ip;
	public GetLocationByIP() {
	}
	public GetLocationByIP(SqlAPI apiString ipthrows PermissionException {
		if(api == null) {
			throw new IllegalArgumentException("Invalid parameter: api");
		}
		if(ip == null || ip.length() > ) {
			throw new IllegalArgumentException("Invalid IP address.");
		}
		this. = api;
		this. = ip;
	}
	public Query<LocationnewWithParameters(Map<StringObjectparametersthrows PermissionException {
		return new GetLocationByIP(
				(SqlAPI)parameters.get("api"),
				(String)parameters.get("ip"));
	}
	public List<Locationexecute() throws IOException {
		List<Locationresults = new LinkedList<>();
		Connection c = null;
		try {
			c.setAutoCommit(false);
			Location l = ipLocation(c);
			if(l != null) {
				results.add(l);
			}
			c.close();
			c = null;
catch(SQLException e) {
			throw new IOException(e);
finally {
			if(c != null) {
				try { c.rollback(); } catch (SQLException e) {}
				try { c.close(); } catch (SQLException e) {}
			}
		}
		return results;
	}
		return "{" +
				"\"ip\":\"" +  + "\"" +
				"}";
	}
New to GrepCode? Check out our FAQ X