ColdFusion in Baltimore Rotating Header Image

January 17th, 2015:

Factual and ColdFusion

Here is how to use the Java driver from Factual¬†in ColdFusion. I wish Factual would support CF. So I’m posting it for anyone to use, and turns out it’s really simple.

 

  1. You can either obtain the Java driver from Factual Github, and get all the dependencies from Maven, or you can download this complete jar package FactualJarLib. Unzip and place all the jar files in your ColdFusion lib folder, and restart the server to enable the driver. You can also dynamically load the jar files (google it).
  2. To use the driver, use the following code. You can substitute the table names and add other vars, just append them to the query string (factual_URL) as below.
  3. [coldfusion]
    <cfscript>
    // set query vars
    limit =20;
    place_type = 150;
    locality = "Baltimore";
    region = "MD";
    offset = 0;
    // create query string
    factual_url = ‘query.limit(#limit#).field("category_ids").includes(#place_type#).field("locality").includes("#locality#").field("region").includes("#region#").offset("#offset#")’;
    /// init driver, add keys
    factual = createObject("Java","com.factual.driver.Factual").init("yourApiKey", "yourSecret");
    // init Query object
    query = createObject("Java","com.factual.driver.Query").init();
    // evaluate built query string
    q=evaluate(factual_url);
    // submit string to query object
    q=factual.fetch("places", q);
    </cfscript>

    <cfdump var="#q#">
    [/coldfusion]

  4. That’s it!!!