Monday, December 19, 2011

Installing Oracle XE 11g on Ubuntu 11.10

Ubuntu is not supported OS for Oracle XE 11g but still we can make it work by following below post. The main issue is due to memory management used by previous version vs ubuntu 11.10.

Friday, December 16, 2011

Oracle XE 11g Post Installation Issue

After installing Oracle XE 11g database, if you get below error when running below command,

[root@*** ~]# /etc/init.d/oracle-xe status

LSNRCTL for Linux: Version 11.2.0.2.0 - Beta on 19-APR-2011 04:07:41

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
  Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*******)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
  Linux Error: 111: Connection refused


then it is an issue with network settings of your OS. The main reason is that the listener.ora was referencing a network settings which was modified after the Oracle XE installation.

The solution is to rename the listener.ora to something different (for example, listener.ora_old) and then restart the database by /etc/init.d/oracle-xe restart

Saturday, June 25, 2011

How to calculate distance between two zipcode?

To calculate the distance between two zipcode, you need a table which stores latitude and longitude for all the cities.
CREATE TABLE `zip_codes` (
  `zip` varchar(5) NOT NULL default '',
  `state` char(2) NOT NULL default '',
  `latitude` varchar(10) NOT NULL default '',
  `longitude` varchar(10) NOT NULL default '',
  `city` varchar(50) default NULL,
  `full_state` varchar(50) default NULL,
  UNIQUE KEY `zip` (`zip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `zip_codes` VALUES ('35004', 'AL', ' 33.606379', ' -86.50249', 'Moody', 'Alabama');

You can use the below logic to calculate the distance:-

import java.lang.Math;
import java.lang.Double;

public int calcDistance(double latA, double longA, double latB, double longB)
{
  double theDistance = (Math.sin(Math.toRadians(latA)) *
                        Math.sin(Math.toRadians(latB)) +
                        Math.cos(Math.toRadians(latA)) *
                        Math.cos(Math.toRadians(latB)) *
                        Math.cos(Math.toRadians(longA - longB)));

  return = (Math.toDegrees(Math.acos(theDistance))) * 69.09;
}

SQL script to setup zipcode table - http://zips.sourceforge.net/

JSON Validator and Formatter

WebCenter Login Setup

How to setup Task List portlet

Excellent article which talks about how to setup task list portlet in webcenter pages.

http://fusione2o.blogspot.com/2011/05/setting-up-task-list-portlets-in.html