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