Tuesday, April 28, 2009

Code to connect to a website

Following is the code i used to test an application .
I did not want the thread and also it did not want it to consume CPU.
I wanted it to use random network delay.

try {
long l=System.currentTimeMillis();
URL ourURL = new URL("http://www.nomsdom.blogspot.com");
HttpURLConnection huc = (HttpURLConnection)ourURL.openConnection();
huc.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; JVM)");
huc.setRequestProperty("Pragma", "no-cache");
BufferedReader reader = new BufferedReader(new

String line = null;
while ((line = reader.readLine()) != null) {
System.out.println("Time taken "+((System.currentTimeMillis()-l)/1000)+"secs");
catch(IOException ioe)
catch(Exception e)
System.err.println("General Exception " + e);

Code taken from here

Wednesday, April 22, 2009

Oracle db connection , Mysql stuff

Oracle jdbc url is
username : system
password: hello


username: hr
password: hr

A very helpfule website
Good Website

Imp links for Mysql setup

Mysql link 1
My Sql link 2

We want MySQL to listen on all interfaces, not just localhost, therefore we edit /etc/mysql/my.cnf and comment out the line bind-address =

Wednesday, April 15, 2009

Friday, April 10, 2009

Changing forgotten password in Oracle

If you log in as a user with the ORA_DBA group, you will be able to get into your instance without a password. Usually the user on your machine that installed Oracle will work.

Just do this at a command prompt (after setting ORACLE_HOME and ORACLE_SID)

sqlplus "/ as sysdba"

Once you've done that, you can "alter user sys identified by xxxxx" to change the SYS password (replace xxxxx with the new one) .

Faced the problem listener was not starting because it did not have access to the log file for writing.

Exported the following variable at command line
$ LSNR=$ORACLE_HOME/bin/lsnrctl
$ SQLPLUS=$ORACLE_HOME/bin/sqlplus
$ export ORACLE_HOME
$ export PATH=$ORACLE_HOME/bin:$PATH
$ /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/lsnrctl status

TNS:net service name is incorrectly specified
Went to ORACLE_HOME above /network.admin/tnsnames.ora to find out the settings.


user - The login user name defined in the Oracle server.

password - The password for the login user.

host - The host name where Oracle server is running.
Default is - the IP address of localhost.

port - The port number where Oracle is listening for connection.
Default is 1521.

SID - System ID of the Oracle server database instance.
SID is a required value. By default, Oracle Database 10g Express
Edition creates one database instance called XE.

Saturday, April 4, 2009


We must be the change we wish to see

Where you used to be, there is a hole in the world, which I find myself constantly walking around in the daytime, and falling in at night. I miss you like hell. ~Edna St Vincent Millay

What is the opposite of two? A lonely me, a lonely you. ~Richard Wilbur

Your absence has gone through me
Like thread through a needle
Everything I do is stitched with its color.
~W.S. Merwin, "Separation"

Why can't we get all the people together in the world that we really like and then just stay together? I guess that wouldn't work. Someone would leave. Someone always leaves. Then we would have to say good-bye. I hate good-byes. I know what I need. I need more hellos. ~Charles M. Schulz

God is closest to those with broken hearts. ~Jewish Saying

If you're going through hell, keep going. ~Winston Churchill

The robbed that smiles, steals something from the thief. ~William Shakespeare, Othello

Wednesday, April 1, 2009

Awk Commands to remember

following example prints the second field of each input record whose first field is precisely
$ awk '$1 == "foo" { print $2 }' filename

following regular expression match accepts any record with a first field that contains ‘foo’:
$ awk '$1 ~ /foo/ { print $2 }' filename

A regexp constant as a pattern is also a special case of an expression pattern. The
expression /foo/ has the value one if ‘foo’ appears in the current input record. Thus, as a
pattern, /foo/ matches any record containing ‘foo’.

Boolean expressions are also commonly used as patterns. Whether the pattern matches
an input record depends on whether its subexpressions match. For example, the following
command prints all the records in ‘BBS-list’ that contain both ‘2400’ and ‘foo’:
$ awk '/2400/ && /foo/' BBS-list

The following command prints all records in ‘BBS-list’ that contain either ‘2400’ or
‘foo’ (or both, of course):
$ awk '/2400/ || /foo/' BBS-list

The following command prints all records in ‘BBS-list’ that do not contain the string
$ awk ’! /foo/’ BBS-list

Good Website for Awk One liners