Thursday 24 May 2012

Convert String to Integer and vise versa

We easily convert String to Integer use of parseInt method and Integer to String use of  toString() method.

String To Integer
Syntax
   Integer.parseInt(Str);
Example :
  String name = "ram";
  Int  i = Integer.parseInt(name);


Integer To String
Syntax
   Integer.toString(intValue);
Example :
  int i = 10;
  String no = Integer.toString(i);


 that's all !!!

Tuesday 15 May 2012

Resolving PacketTooBigException in MYSQL

Sometime if you use MySql you  may get the following error when,Installing and migration of your project.that error like  com.mysql.jdbc.PacketTooBigException:Packet for query is too large (4739923 > 1048576).
 For that you have to excute the following Query in MySql


                    set global max_allowed_packet=1817776

ReStore MYSQL Dump in Linux

ReStoring  MySql dump use of the following command

mysql -u[UserName] -p[Password] dbName < /<directory of file saved>/filename.sql

MYSQL Dump in linux

You can take MYSQL Dump using the following command

mysqldump  -u[UserName] -p[Password] dbName > /<directory to save>/filename.sql

Taking multiple databases dump at the same time

mysqldump  -u[UserName] -p[Password] [dbName1] [dbName2] ... > /<directory to save>/filename.sql

Taking dump of  Particular table in databases

mysqldump  -u[UserName] -p[Password] [dbName] [table_Name] > /<directory to save>/filename.sql

Takinge dump of  all databases

mysqldump  -u[UserName] -p[Password] -all-databases > /<directory to save>/filename.sql

Monday 14 May 2012

Fixing problem of Eclipse WorkSpace failed to Startup


There can be a lot of issues in Eclipse startup . But there is one of the quite common one is eclipse resources cache or state gets out of sync/corrupted.This can happen when your IDE crashes OR also without crashing. For fixing that bug just remove ".snap" file from Workspace. See below how to delete
these ".snap" file.

<directory of workspace>/.metadata/.plugins/org.eclipse.core.resources/ 

inside of that you will find ".snap" file just delete that file.Then  Eclipse started fine.

OR You can use use this command also
                  " sudo eclipse -clean"
it also working fine


Overcome Problem of SVN Working Copy xxx locked and cleanup failed

Sometime You will get error in svn update or commit like
svn: Working copy '/home/test/IdeaMed/Project/src/main' locked; try performing 'cleanup'.


For that just go Team--->cleanup then that error will go away

Sometime You will get error like that also
svn: Working copy '/home/test/IdeaMed/Project/src/main' locked; and cleanup failed .


We should also be careful not to interrupt SVN operations, though sometimes a error may occur and this  could cause the ".lock" file to not be removed.

Generally  ".lock" file is created and it decides lock/unlock state checking the existince of this file. If you delete this ".lock" file only, then the problem will go away.

".lock" normally Placed in WorkSpace folder.Go to WorkSpace folder and press Ctrl+h  then you will find ".metaData".Inside of  ".metaData" delete the ".lock" file 


Otherwise in command window simply give the following command it will work
          "svn cleanup"

Uninstall Firefox in ubuntu

We can uninstall firefox in ubuntu two ways.

1 .Synaptic Package Manager

         just Go System-->Administration-->Synaptic Package Manager


It shows how many packages installed in ubuntu.


In that menu search firefox use of QuickFilter .Then select that  application right click select mark for completly removal then click apply.That's it application removed.

or you can Go ubuntu software center in application menu and search firefox then select that application and click uninstall.But its not working fine.

2.Terminal

      You can remove firefox via terminal using these following command.
                   "sudo apt-get purge firefox"
      Delete .mozilla/firefox/ , macromedia,adobe into your home directory.these can contain "Flash Cookies" stored by the browser.Finally delete add ons in etc folder.
          "rm -rf /home/<user>/.mozilla/firefox/  /home/<user>/.adobe/  /home/<user>/.macromedia/ /etc/firefox/ /usr/lib/firefox/  /usr/lib/firefox-addons/"



 



Saturday 12 May 2012

Removing files and directories using Linux Command

You can remove particular directories or files use of " rm "command in linux

rm [options] filename


if you want to remove full directory means use these command

rmdir [options] directory


options are -r ,-rf,-v like that

Example:

  •   rm -rf  test.txt -->removes test.txt file
  •   rmdir /home/src/webapp -->removes the directory
  •   rm * --->removes every thing from that current path
  •   rm *.jsp --->rremoves all files end with jsp files from the current path






CHMOD in linux

chmod command gives access mode for users.Each time no need to go that folder directories and right click the folder and changing the permisson.just Go to the command prompt window and give the command chmod.


chmod who=permissionmode directory or folder or file


This gives “who” the specified permissionmode for a given filename.
 "who" list of representation of three different roles:
  • u is for user,
  • g is for group,
  • and o is for others.
"permissionmode" is list of representation of three different permissions:
  • r is for read permission,
  • w is for write permission,
  • x is for execute permission.
CHMOD can also to attributed by using Numeric Permissions:
  • 400 read by owner
  • 040 read by group
  • 004 read by anybody (other)
  • 200 write by owner
  • 020 write by group
  • 002 write by anybody
  • 100 execute by owner
  • 010 execute by group
  • 001 execute by anybody
use of the numeric codes use can combine any of numeric codes and form one number use of that give access mode to depend on user


List of some useful chmod by numbers

  1.         chmod  -R 777 ---->full access to everyone
  2.         chmod  -R 666 ---->read and write permission to everyone
  3.         chmod  -R 755 ----> Anyone write to the file
  4.         chmod  -R 644 ----> Read and write by owner and read by every one else

        -R is noting but recursive


Example To Form Numbers use of Numeric Codes:


  400+040+004+200+100+010+001 = 755 this represents (-rwxr-xr-x).


   chmod  -R 777 test.html means giving full access to the .html file
or you can give permission like this also
   chmod u+x test.html  which gives execute permission for user.
   Like wise you can give multiple permission also.
  

Friday 11 May 2012

"mkdir" command in linux

'mkdir' command used for creating one or more directories .


For creating 
mkdir [options] directories


options means whether you giving permission for the directories and adding help messages and soon.
options                 explanation
-m                   giving access mode 
 -v                    Print help message for each directory created

Example:


Creating simple Directories
     1   mkdir /home/test /backup


Creating simple Directories with access mode
     1   mkdir -m 777 /home/test /backup
          Giving full access to /home/test /backup
     2   mkdir -m 666 /home/test /backup
         Giving read and write permission to /home/test /backup

COPY command in Linux

You can copy files from one directory to another directory using command prompt window .The following commands used to copying the files


"cp" --->Copies files from one location to another.


cp sourceDirectory desinationDirectory

"cp test.txt desinationDirectory"

         Copies test.txt in the current directory to the desinationDirectory directory.

"cp /home/public/test.txt /home/public/backup/test.html"

         Copies the test.txt file in the public directory into the public/backup directory as test.html The files are identical however have different names.

"cp *.txt desinationDirectory"

        Copy all files ending in .txt into the desinationDirectory directory.

"cp -r /home/public/files/* /home/public/backup"

         Copies all the files, directories, and subdirectories in the files directory into the backup directory.

"yes | cp /home/public/test/* /home/public/target"

         Copies all the files and subdirectories in test into the target directory. If files with the same name exist or it's prompted to overwrite the file it answers yes.



Wednesday 2 May 2012

Setting background color and font display color dynamically for LabelField in Extjs

We can set colors for LabelField dynamically in Extjs by use of the function setText().
Example :


 var test = new Ext.form.LabelField({
id: 'name',
                fieldLabel:'Name',
                width: 200,              
                height: 100,
                xtype: 'label',
});


normally it displays like these



in runtime you dynamically apply colors for "back -ground"  and "fonts" use these field id

Ext.getCmp('name').setText('<span id="ot" style="back-ground:yellow;color: red; display: block"><center><b>Welcome to My Blogspot </b></center></span>',false);
In runtime it shows




The false argument will prevent the html tags from being mangled by the function.


you can apply all HTML tags inside of these function

Adding Tomcat server inside Eclipse

We can Tomcat Server inside Eclipse and run run your program use of that server.For adding tomcat inside  of eclipse just we have do following steps:

STEP 1 : Before Configure of tomcat in your eclipse just download tomcat and install it any location of your computer.

STEP 2 : Then in Eclipse project Explorer just right click New->Others->Server

STEP 3 : now inside of Server choose server then click next

                                   

STEP 4 : In Apache choose Version of Tomcat then click to next

                                         

STEP 5 : Just browse the location where is tomcat installed in your hard drive then click finish


                                             
       now  inside of project explorer of ecplise server coming like these

                   

          You can add via window-->preferences -->server -->runtime environment-->add server and remaining steps are same as follow from third steps      

What's difference between SET and LIST in Java?

"SET" never allows duplicate elemements.It contains element in unique and stores elements in an         unordered way.In Set we retrive  data only in forward direction.

"LIST"  allows duplicate elemements.It contains element in non-unique and stores elements in an ordered                                   way.In List you can retrive both forward and backward direction.