Oct 31

The Java Language Specification can be found here.

written by objects \\ tags: , ,

Oct 11

The DBUtil library from Apache provides a set of class for doing a variety of standard database tasks.

eg. To make a query becomes as simple as the following, providing the result set as a List of arrays where each list elements contains a row.


QueryRunner runner = new QueryRunner();
ArrayListHandler handler = new ArrayListHandler();
List<Object[]> result = runner.query(connection,
    "SELECT * FROM MyTable WHERE name=?", handler, "Joe Smith");
DbUtils.close(conn); 

written by objects \\ tags: , , , ,

Oct 06

The Spherical law of cosines gives a pretty accurate result that will be sufficient for most applications.

/**
    lat, longs are in radians
*/
public static double distance(double lat1, double lon1, 
                                              double lat2, double lon2) {
    return R * Math.acos(Math.sin(lat1) * Math.sin(lat2) +
        Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon1 - lon2));
}

private static final double R = 6371.0;  // earths mean radius in km

written by objects \\ tags: , ,