Friday, November 19, 2010

ava.security.AccessControlException: access denied (java.net.SocketPermission

Some times you may see,

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E; .NET CLR 3.0.30618; .NET CLR 3.5.30729)
Timestamp: Fri, 19 Nov 2010 21:30:15 UTC


Message: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:5000 connect,resolve)
Line: 53
Char: 9
Code: 0
URI: http://localhost/asg4/javascript/tttgame.js


Solution:

Add following line to java.policy file jre/lib/

I added permission line to c:\program files\java\jre\lib\security \ java.policy file

permission java.net.SocketPermission "localhost:1024-", "listen,connect,accept,resolve";

Thursday, November 18, 2010

How to Linux OS name?

way 1: uname -a . it wont give you vendor name....it print flavor of linux

$ uname -a
Linux willard 2.6.24-28-server #1 SMP Thu May 27 00:58:42 UTC 2010 i686 GNU/Linux

way 2: cat /proc/version

$ cat /proc/version
Linux version 2.6.24-28-server (buildd@rothera) (gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)) #1 SMP Thu May 27 00:58:42 UTC 2010


When I run on fedora,

$ uname -a
Linux adsl-99-140-126-11.dsl.sfldmi.sbcglobal.net 2.6.23.1-42.fc8 #1 SMP Tue Oct 30 13:55:12 EDT 2007 i686 athlon i386 GNU/Linux

$ cat /proc/version
Linux version 2.6.23.1-42.fc8 (kojibuilder@xenbuilder4.fedora.phx.redhat.com) (gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)) #1 SMP Tue Oct 30 13:55:12 EDT 2007

Monday, October 25, 2010

which.bat

@echo off
setlocal
if "%1" == "" goto noArg

set fullpath=%~$PATH:1
if "%fullpath%" == "" goto notFound
echo Found in PATH: %fullpath%
goto end

:noArg
echo No Argument specified
goto end

:notFound
echo Argument "%1" not found in PATH


:end
endlocal

Bad Request in apache? Not able to start server?

After installing apache in windows, you may see problems like

Invalid request or Bad request..

This may be because of another program which already using port 80.
you can debug this kind of problems using a command which list
all ports currently in use and program names too

use this command to see which program is using which port
C:\>netstat -a -b -n -o

get PID from above program, and go to task manager to get program / application
name.

In my case svchost is using :http port by default. its may be virus. i terminated it

and you can also see hosts file in
C:\WINDOWS\system32\drivers\etc for any errors.


or if some know program is using 80 port (like tomcat, weblogic...etc) then you
can configure other port like 8888 in httpd.conf ( apache_home/conf)

pache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

To fix it, we need to edit the /etc/apache2/httpd.conf or /etc/apache2.conf and add the following line:

ServerName nameofserver

hosts file in windows

C:\WINDOWS\system32\drivers\etc\hosts

Add machines:

127.0.0.1 localhost

Tuesday, October 19, 2010

Code Names for JDK?

J2SE 5.0 Tiger

J2SE 6.0 Mustang

Wednesday, October 6, 2010

PHP program to read a table from MYSQL?

\n";
echo"
student No
Student Name
Student fee
";

while($row = mysql_fetch_row($resultset)){
echo "\n";

foreach($row as $val){
echo "$val\n";
}
echo "\n";
}
echo "";

mysql_select_db($database_name);
mysql_close();
?>

Installing Apache, PHP,MYSQL?

Step 1:
===================================================
Install Apache http server to c:\Apache2.2.11

Run Apache and test http://localhost

we can configure http port, server root, document root...etc
in c:\Apache2.2.11\conf\httpd.conf


Step 2:
====================================================
install or unzip PHP 5 to c:\php5.2.6

create php.ini in c:\php5.2.6
make sure php5apache2_2.dll is in c:\php5.2.6


Step 3: Link Apache and PHP.
======================================================
Open httpd.conf in c:\Apache2.2.11\conf

add following three lines in LoadModules area

#Let apache where php DLL present to process php files
LoadModule php5_module "c:/php5.2.6/php5apache2_2.dll"


#Let apache know php can be handled
AddType application/x-httpd-php .php

# let Apache know path to php.ini
PHPIniDir "c:/php5.2.6"

You can test php configuration. create a php fiel phpinfo.php in htdocs of
apache server. then issue
http://localhost/phpinfo.php

phpinfo.php
------------
phpinfo();
?>


Step 4: Configure MySQL
===========================================
install MYSQL server to c:\mysql5.1
start mysql server from command prompt ( if you havent installed
mySQL as service. we can choose this option while installaiton)

cmd > mysqld (press enter)


Then log into mySQL

cmd> mysql -u root (press Enter) .you may need to enter password
using -p option (if you set root password in installaiton)

Now see list of databases
mysql> show databases;

To see list of existing users,

mysql> select user,host,password from mysql.user;

Here mysql is MYSQL server system database to keep system tables

to create new database
mysql> create database if not exists wp436;

to create new user

mysql> create user 'suresh'@'localhost' identified by 'suresh123';


Then to grant all privileges to wp436 to user suresh,

mysql>use wp436;
mysql> grant select,insert,update,delete,create,drop on wp436.* to 'suresh'
identified by 'suresh123';


Now user is ready for login;






cmd> mysql -u suresh -p (press enter.prompt for password)

now user can see list of databases having access

mysql>show databases;


Now create a table in wp436 database
user first select the database

mysql> use wp436;

mysql>create table student(sno integer(6),sname varchar(50),sfee double(8,2),primary key(sno));


Now insert data

mysql> insert into student values(100,'aaa',1000);

now commit,

mysql> commit;


Step 5: Connect PHP and MYSQL
====================================

modify php.ini to enable

extension=php_mysql.dll
extension=php_mysqli.dll

And copy the "php_mysql.dll" to c:\WINDOWS, and the "libmysql.dll" to the c:\WINDOWS\system32. You will find these dlls in the ext directory in the PHP installation directory.

we can do more changes in [MYSQL] section of php.ini

Note: irritation with beep sound provided by msql?
use cmd> net stop beep :)



Are you getting could not connect can't connect to mySQL server on localhost(10061)

Sol: Checl mysqld is running or not. if not run it
cmd>mysqld



Step 6: Sample PHP Program to test db connection:
=======================================================





call this php file using

http://localhost/dbtest.php

Thursday, September 30, 2010

Is oracle creating an index when we create a primary key?

Yes. In oracle 9i and Oracle 10g if you mention
primary key constraint in the create table statement
oracle Automatically creating an index with same
name as constraint

Ex;SY0023456

Thursday, September 23, 2010

How do you add column and modify its size in oracle?

alter table student add
address varchar2(20);

alter table student MODIFY
address varchar2(40);

How do you delete duplicate rows using row ID concept.Assume no Primary key in the table

-- deleting duplicate rows
--using row id concept
drop table emp;
create table emp (empno number(6) , ename varchar2(20), sal number(8));
insert into emp values(100,'aaa',4000);
insert into emp values(200,'bbb',1000);
insert into emp values(300,'ccc',5000);
insert into emp values(400,'ddd',3000);
insert into emp values(500,'eee',400);
insert into emp values(100,'aaa',4000);
insert into emp values(200,'bbb',1000);
insert into emp values(300,'ccc',5000);
insert into emp values(400,'ddd',3000);
insert into emp values(500,'eee',400);

select * from emp order by empno;

-- RowID concept... Unique for each row...same row id
-- if rows are same
SELECT min(rowid)
FROM emp
group BY empno,ename,sal;



-- delete min row id. here we need to
-- list columns in group by clause
-- 5 rows deleted
DELETE FROM emp
WHERE rowid not in
(
SELECT MIN(rowid)
FROM emp
GROUP BY empno, ename, sal
) ;

-- 3 rows deleted
select * from emp order by empno;

How to find top n salaries in Oracle table?

create table emp (empno number(6) primary key, ename varchar2(20), sal number(8));

insert into emp values(100,'aaa',4000);
insert into emp values(200,'bbb',1000);
insert into emp values(300,'ccc',5000);
insert into emp values(400,'ddd',3000);
insert into emp values(500,'eee',400);

-- Using Row Number
SELECT *
FROM (
SELECT * FROM emp ORDER BY sal DESC
)
WHERE ROWNUM <= 3;

-- Using oracle rank() Function
SELECT *
FROM ( SELECT empno,ename,sal,RANK() OVER (ORDER BY sal DESC) sal_rank
FROM emp )
WHERE sal_rank <= 2;

Wednesday, September 15, 2010

SQL loader control file example

Assume data file is not delimited file. file contains data
continuously and we know that data length . i.e Fixed-Width Files
we can also use sql loader for Delimited files

LOAD DATA
INFILE '#INFILE#'
APPEND
INTO TABLE TEST_SCORE (
REPORTING_YEAR POSITION(01:02) CHAR,
LAST_NAME POSITION(03:27) CHAR,
FIRST_NAME POSITION(28:43) CHAR,
MI POSITION(44:44) CHAR,
IMP_FILENAME CONSTANT '#INFILE#',
IMP_FILE_DATE DATE "YYYYMMDD" "#DATE#" ,
IMP_FILE_SEQ CONSTANT #INTEGER#
)

'#INFILE#' is the input data file name.

TEST_SCORE is the target table name

you can call sql loader utility using following command

$sqlldr username/password@dbsid control=control_file_name log=log_file_name data=data_file_name

what is Oracle database control file?

Database control files are
binary files containing information about the physical structure of your database.

what is SQL Loader?

SQL*Loader is an Oracle-supplied utility that allows you to load data from a flat
file into one or more database tables. That’s it. That’s the sole reason for
SQL*Loader’s existence.

The basis for almost everything you do with SQL*Loader is a file known as the
control file. The SQL*Loader control file is a text file into which you place a
description of the data to be loaded. You also use the control file to tell
SQL*Loader which database tables and columns should receive the data that you
are loading.

What we check while dropping column?

In production, Before dropping any field
on a table, its recommended to check whether
any views are using that fields or not.

for example, As part of encryption if you drop
SSN field on a table without checking any views
then all views shows errors.

So be careful....

Can create a table as with NULL fields?

I am trying to create a table using

create table student as
select
a,
'' b,
c
from student_temp;

This query fails. we can create table in this way using zero
length fields or NULL fields.
To solve this, we generally use NULL place holder while
creating table and then replace that with NULL
once table is created.

Tuesday, September 14, 2010

How companies got named?

Mercedes:
This was actually financier's daughter's name



Adobe:
This came from the name of the riverAdobe Creek that ran behind the house of founder John Warnock



Apple Computers:
http://track.vcommission.com/aff_i?offer_id=774&aff_id=1018&file_id=4057It was the favourite fruit of founder Steve Jobbs. He was three months late for filing a name for the business, and he threatened to call his company Apple Computers if the other colleagues didn't suggest a better name by 5 o'clock that day



CISCO:
It is not an acronym as popularly believed. It is short for San Francisco .



Compaq:
This name was formed by using COMp, for computer and PAQ to denote a small integral object



Corel:
The name was derived from the founder's name Dr. Michael Cowpland. It stands for COwpland Research Laboratory.



Google:
The name started as a joke boasting about the amount of information the search-engine would be able to search. It was originally named 'Googol',a word for the number represented by 1 followed by 100 zeros. After founders - Stanford graduate students Sergey Brin and Larry Pagepresented their project to an angel investor; they received a cheque made out to 'Google'.



Hotmail:
Founder Jack Smith got the idea of accessing e-mail via the web from a computer anywhere in the world. WhenSabeer Bhatia came up with the business plan for the mail service, he tried all kinds of names ending in 'mail' and finally settled for hotmail as it included the letters"html" - the programming language used to write web pages. It was initially referred to as HoTMaiL with selective uppercasing



Hewlett Packard :
Bill Hewlett and Dave Packard tossed a coin to decide whether the company they founded would be called Hewlett-Packardor Packard-Hewlett.



Intel:
Bob Noyce and Gordon Moore wanted to name their new company ' Moore Noyce' but that was already trademarked by a hotel chain so they had to settle for an acronym of INTegrated ELectronics.



Lotus (Notes) :
Mitch Kapor got the name for his company from 'The Lotus Position' or'Padmasana' . Kapor used to be a teacher oftranscendental Meditation of Maharishi Mahesh Yogi.



Microsoft:
Coined by Bill Gates to represent the company that was devoted to MICROcomputer SOFTware. Originally christened Micro-Soft, the '-' was removed later on.



Motorola:
Founder Paul Galvin came up with this name when his company started manufacturing radios for cars. The popular radio company at the time was called Victrola.



Sony:
It originated from the Latin word 'sonus' meaning sound, and 'sonny' a slang used by Americans to refer to a bright youngster.



SUN:
Founded by 4 Stanford University buddies, SUN is the acronym forStanford University Network. Andreas Bechtolsheim built a microcomputer;Vinod Khosla recruited him and Scott McNealy to manufacture computers based on it, and Bill Joy to develop a UNIX-based OS for the computer.



Apache:
It got its name because its founders got started by applying patches to code written for NCSA's httpd daemon.. The result was 'A PAtCHy' server --thus, the name Apache Jakarta (project from Apache):A project constituted by SUN and Apache to create a web server handling servlets and JSPs. Jakarta was name of the conference room at SUN where most of the meetings between SUN and Apache took place.



C:
Dennis Ritchie improved on the B programming language and called it 'New B'.He later called it C. Earlier B was created by Ken Thompson as a revision of the Bon programming language (named after his wife Bonnie).



C++:
Bjarne Stroustrup called his new language 'C with Classes' and then 'newC'. Because of which the original C began to be called 'old C' which was considered insulting to the C community. At this time Rick Mascittisuggested the name C++ as a successor to C.



Java:
Originally called Oak by creator James Gosling, from the tree that stood outside his window, the programming team had to look for a substitute as there was no other language with the same name. Java was selected from a list of suggestions. It came from the name of the coffee that the programmers drank.



LG:
Combination of two popular Koreanbrands Lucky and Goldstar.



Linux:
Linus Torvalds originally used the Minix OS on his system which here placed by his OS. Hence the working name was Linux (Linus' Minix). He thought the name to be too egotistical and planned to name it Freax(free+ freak + x).His friend Ari Lemmke encouraged Linus to upload it to a network so it could be easily downloaded. Ari gave Linus a directory called linux on his FTP server, as he did not like the name Freax.(Linus' parents named him after two-time Nobel Prize winner Linus Pauling) .



Mozilla:
When Marc Andreesen, founder of Netscape, created a browser to replace Mosaic (also developed by him), it was named Mozilla (Mosaic-Killer, Godzilla) .The marketing guys didn't like the name however and it wasre-christenedNetscape Navigator.



Red Hat:
Company founder Marc Ewing was given the Cornell lacrosse team cap (with red and white stripes) while at college by his grandfather. He lost it and had to search for it desperately. The manual of the beta version of Red Hat Linux had an appeal to readers to return his Red Hat if found by anyone!



SAP:
"Systems, Applications, Products in Data Processing", formed by 4 ex-IBM employees who used to work in the 'Systems/Applicatio ns/Projects' group of IBM.



SCO (UNIX):
From Santa Cruz Operation. The company's office was in Santa Cruz .



UNIX:
When Bell Labs pulled out of MULTICS (MULTiplexed Information and Computing System), which was originally a joint Bell/GE/MIT project, KenThompson and Dennis Ritchie of Bell Labs wrote a simpler version of the OS.They needed the OS to run the game Space War which was compiled underMULTICS. It was called UNICS - UNIplexed operating and Computing System by Brian Kernighan. It was later shortened to UNIX.



Xerox:
The inventor, Chestor Carlson, named his product trying to say `dry' (asit was dry copying, markedly different from the then prevailing wet copying). The Greek root `xer' means dry.



Yahoo!:
The word was invented by Jonathan Swiftand used in his book 'Gulliver's Travels' . It represents a person who is repulsive in appearance and action and is barely human. Yahoo! founders Jerry Yang andDavid Filo selected the name because they considered themselves yahoos.



3M:
Minnesota Mining and Manufacturing Company started off by mining the material corundum used to make sandpaper.

Friday, August 27, 2010

delete files older than one year

find ./ -type f -mtime +365 -exec rm {} \;

Not to consider sub directories

find ./ -type f -maxdepth 1 -mtime +365 -exec rm {} \;

Copy a file with time preserve?

cp -p file1 detinationdir

Wednesday, August 25, 2010

How do you move files from linux to windows using ftp?

1. start ftp service in linux
2.In windows open a command prompt.

then change to directory where you want to place
downloaded files

G:\windows-backup>ftp 143.143.143.143
Connected to 143.143.143.143.
220 (vsFTPd 2.0.6)
User (164.76.152.37:(none)): suresh
331 Please specify the password.
Password:
230 Login successful.
ftp> cd /tmp/linuxbackup --> Directory in linux where files present
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
fullback.cpio
fullback.md5
fullback00
fullback01
fullback02
fullback03
226 Directory send OK.
ftp: 77 bytes received in 0.00Seconds 77000.00Kbytes/sec.
ftp> bin
200 Switching to Binary mode.
ftp> prompt n
Interactive mode Off .
ftp> mget fullback0*
200 Switching to Binary mode.
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for fullback00 (4294967296 bytes).

How to start ftp service in Ubuntu?

Start:
$ sudo /etc/init.d/vsftpd start

Stop :

$ sudo /etc/init.d/vsftpd stop

restart:

$ sudo /etc/init.d/vsftpd restart

How do you split a big file into small chunks?

I have big file of 15GB. I want to split this file
into 4GB pieces so that i can burn DVDS. you can
apply following Command

$sudo split -d -b4096m fullback.cpio fullback

above command creates fullback00,fullback01,...etc

How do you see file size in GB?

go to folder where files exits

$cd /tmp/backup_folder

$ du -ahl
17G ./fullback.cpio
.

ex:
suresh:tmp/willardbackup$ du -ahl
4.1G ./fullback01
2.1G ./fullback03
15G ./fullback.cpio
4.1G ./fullback02
4.1G ./fullback00
4.0K ./fullback.md5
29G

How to see Oracle version details?

Connect to your account through sqlplus. then run following:

In oracle 9i,

SQL> select banner from V$VERSION;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
PL/SQL Release 9.2.0.8.0 - Production
CORE 9.2.0.8.0 Production
TNS for Solaris: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production


In Oracle 10g,

SQL> select banner from V$VERSION;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

Thursday, August 12, 2010

How do you restore backup?

How do you restore backup?

1. copy the cd files to a windows system
2. copy the files to a linux system
3. concatenate the files: >cat fullback00 fullback01 fullback02 fullback03 fullback04 fullback05 > fullback.cpio
4. run checksum on fullbackup.cpio; checksum should match value in fullback.md5: >md5 fullbackup.cpio
5. restore archive to a mount point (not live). From the mount point, execute: >cpio -idmv < path_to_archive_file/fullback.cpio

How do you make Entire file system backup in Ubuntu

1. first stop oracle if it is installed

2. find and cpio are the commands used to create backup tar file

Find list of files to be backed up and create archive

find command :
============
xdev : options tells only search in current file system . i.e ' / '
To omit paths in /tmp, /proc and /var/tmp we use prune option. we no need to take a backup of these temporary
files. use -prune option for that
-o options is like OR conidtion to add two are more prunes
-print options prints path

cpio command
===========
it creates and un-creates archived cpio files. And also is capable of copying files to things other than a hard disk.

-o options tells that "(copy out) : cpio -o reads the standard input to obtain a list of path names and copies those files onto the standard output."
-v : for verbose

switch to root user. $sudo su - (to get permissions to all files)

take relative path backup using following command.

find ./ -xdev
-path /tmp -prune -o
-path /proc -prune -o
-path /var/tmp -prune -o
-print | cpio -ov > /tmp/fullback.cpio

so the single line commad is

>find ./ -xdev -path /tmp -prune -o -path /proc -prune -o -path /var/tmp -prune -o -print | cpio -ov > /tmp/fullback.cpio

step 3: Now we can restart oracle

>/etc/init.d/dboracle start ( dboraz is a service to be exist)

Step 4: create message digest for archive file for security reasons. this is useful while
restoring backup. it used to check correctness of backup file before starting restore.

>md5 fullback.cpio > fullback.md5


Step 5: Now split big file into small pieces so that we can write them into a DVD (4.7 GB)


>split -d -b4096m fullback.cpio fullback [yields fullback00, fullback01, ... fullbackxx]

Step 6:

burn pieces fullbackxx to DVDs along with message digest file. fullback.md5

Teradata Architecture

Teradata is data base which supports tera bytes of data or even pega bytes now in
data warehouse solution.
Teradata strength is parallelism and shared nothing architecture. It keeps parallelism every ware
It works on MPP (Multi Parallel Processing) .