Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Monday, June 18, 2012

Dropping table that has many objects dependent on it

Dropping table automatically,
the program throws error:

Exception in thread "Thread-3" java.lang.NullPointerException
Changed the drop table query statement in Java from
stmt.execute(droptable);
          to
stmt.executeUpdate(droptable);

Still it displayed the same error.

While executing the query on pgadmin, it displayed the error:

ERROR: cannot drop table h*** because other objects depend on it
HINT: Use DROP ... CASCADE to drop the dependent objects too.

Too many triggers and views are dependent on the table

Changed the Drop table statement from

DROP TABLE TABLENAME
to
DROP TABLE TABLENAME CASCADE

Program works fine.

Tuesday, June 12, 2012

Is it possible to run a .bat file in Linux?

No

You will have to change the file to the Linux format, .sh file and then execute it.


Example:

I have a TESTTool folder which contains 2 folders:
1. bin folder with a Tool.jar file &
2. lib folder with Communication.jar file in it


start.bat file looks like this:

cd bin
java -classpath ..\lib\*;Tool.jar testtool.UIFrame


..\lib\* command selects all files in the folder lib.


The folder was added in Ubuntu PC and then provided permission to it.
And the file start.bat was Saved as start.sh file.

But while executing the application, it throws error :

Could not find the Communication class..

Issue 1:
Linux will not select the files in the folder using the command,
..\lib\*;

You have to specify the jar file in the lib folder.

Issue 2
After saving a .bat file to .sh file,
You have to convert the .sh file into linux format using the command
dos2unix start.sh


The start.sh file will look like:

cd bin
java -classpath ../lib/Communication.jar:Tool.jar testtool.UIFrame

Friday, July 29, 2011

Change postgresql password on Ubuntu


How to change postgresql password on Ubuntu

 
I’m using Postgresql-8.3  on Ubuntu 9.04.

Initially , take pg_hba.conf from /etc/postgresql/8.3/main/
In that you will find an entry like this,
host    all         all         172.16..0/24        md5

Change it to
host    all         all         172.16..0/24        trust

Then restart the postgresql database..
if it is ubuntu use the command /etc/init.d/postgresql restart 

Now issue the command
sudo psql -h -d -U postgres
(it should not ask for postgresql password..). 

It will ask for your unix password
Then give the command
alter user postgres with password 'new password'
to change the password..
Thats it.. 

Monday, December 13, 2010

Starting & Stopping services on Ubuntu bootup

my@my-desktop:~$ sudo su
Provide the command update-rc.d YOURSERVICENAME defaults in terminal.

root@my-desktop:/home/my# update-rc.d YOURSERVICENAME defaults

This will display the following:
Adding system startup for /etc/init.d/YOURSERVICENAME ...
/etc/rc0.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc1.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc6.d/K20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc2.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc3.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc4.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME
/etc/rc5.d/S20YOURSERVICENAME -> ../init.d/YOURSERVICENAME

Restart the PC. The service YOURSERVICENAME will be started automatically on PC boot up.

To remove the service on PC boot

Provide the command,update-rc.d YOURSERVICENAME remove in terminal.
root@my-desktop:/home/my# update-rc.d YOURSERVICENAME remove

Tuesday, November 23, 2010

RMI on Ubuntu 9.04

I was having a problem with RMI running on Ubuntu PC (Ubuntu 9.04).

Whenever I tried to run my RMI program on Ubuntu PC, it showed the error,
java.rmi.ConnectException: Connection refused to host 127.0.1.1; nested exception is: java.net.ConnectException: Connection refused.
I have no idea why the host is here 127.0.1.1 ...

I tried out in many Ubuntu PC’s and everywhere it showed this error.

Found a solution to this problem:
I checked the /etc/hosts on Ubuntu machine and saw that 127.0.1.1 was mapped to ubuntu-PC name, so I've rewritten it to my correct LAN IP.

The /etc/hosts file in my PC looks like this
127.0.0.1 localhost
127.0.1.1 MYPCNAME

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


Using the command vi /etc/hosts, I changed the 2nd line to

127.0.0.1 localhost
172.16.1.1 MYPCNAME

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


After that it worked fine!