Thursday 16 May 2013

Add Mysql connector in eclipse classpath

Add Mysql connector in eclipse classpath

1. Download mysql connector jar from
http://dev.mysql.com/downloads/connector/j/
2. Open eclipse in java EE perspective (top right corner)
3. Right click the project go to Properties.
4. Choose Java Build Path and then Select Libraries tab
5. Click Add External JARs  and add the path of the mysql connector jar
6. Click Ok button and clean and build the project














Properties window for my java project

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver error

Issue

When I try connect my java program to mysql database using eclipse,i am getting the run time error
 "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver"

Solution

The reason for the error is you don't have mysql-connector.jar in your Classpath. This jar
contains "com.mysql.jdbc.Driver" class and it must be present in java classpath in order to successful connection to mysql database.
you can downlad mysql-connector.jar from
http://dev.mysql.com/downloads/connector/j/

Click here for adding mysql connector jar to eclipseclass path




Wednesday 15 May 2013

Php mail tagged as Spam in Gmail Issue fixed

Issue

When I send mail using PHP mail() function,the mail is sent to the Spam folder in GMail.

Solution

You can fix this issue by using the fifth parameter in the mail function to build the header with a valid From address.

PHP Code

<?php 
 
$to 
'you@gmail.com';


$from 'you@yourserver.com';


$message 'Hello';

$subject 'Test Mail';


mail($to$message$subject"From: $from""-f$from");


?> 
 

Monday 29 April 2013

XAMPP is currently only available as 32 bit application. Please use a 32 bit compatibility library for your system.

XAMPP is currently only available as 32 bit application. Please use a 32 bit compatibility library for your system.

This issue mainly faces when you are trying to install xampp in CentOS. It is because CentOS distro and installation lack many of the libraries  including 32 bit compatibility libraries. So it requires more work to get XAMPP running than on other distros like Ubuntu.

Steps to resolve the issue
1. To get 32 bit compatibility libraries type the below command in terminal
     yum -y install glibc* libstd* ld-linux.so.2
2. Start the xampp from terminal
    /opt/lampp/lampp start 

 

Thursday 25 April 2013

Install Burrows-Wheeler Aligner (BWA) in Linux

Steps to install BWA in linux machine

1. Download BWA from http://bio-bwa.sourceforge.net/
2. Save bwa-0.7.4.tar.bz2 it to your drive (eg: /usr/username)
3. Open the terminal from /usr/username and untar using the command  tar -xvf  bwa-0.7.4.tar.bz2
4. bwa-0.7.4 folder will be created in /usr/username.
5. Change directory to bwa-0.7.4 using command cd  bwa-0.7.4
6. Type command make
7. Create a file bwa.sh in etc/profile.d
8. Open the file and type
    #!/bin/bash
    BWA_HOME=/usr/username/bwa-0.7.3a
    PATH=$BWA_HOME:$PATH
    export PATH

9. Save and close the bwa.sh
10. Open terminal from etc/profile.d
11. Type command
    chmod 755 bwa.sh
12. To check the installation , open the terminal and type bwa.


Friday 15 March 2013

Setting java path in linux

After installing JDK or JRE on Linux/Unix platform, you have to set PATH environment variable so that you can run the executables (javac.exe, java.exe, javadoc.exe, and so on) from any directory without having to type the full path of the command.
 
 Steps to set up java path in linux

1. Create a java.sh file in /etc/profile.d directory with content as follows: 
 
#!/bin/bash
           
JAVA_HOME=/usr/java/jdk1.7.0_17
                    
PATH=$JAVA_HOME/bin:$PATH
                                       
export PATH JAVA_HOME
 
The file contains various shell commands which set and export necessary environment variables for Java. Shell settings from configuration files in the /etc/profile.d directory are gathered by/etc/profile during login, setting up user environment information for every user.  
 
2.  Assign execute permissions:
 
# chmod 755 java.sh

3. You can verify the path  by typing the below command in the terminal

# java -version 

Wednesday 13 March 2013

MySQL: The total number of locks exceeds the lock table size

When you are trying to run an update or insert query in a database which contains huge amount of data (crore) in xampp - MySQL, you might see this error

ERROR 1206 (HY000): The total number of locks exceeds the lock table size

Running out of space for locks usually indicates that the small default size of the InnoDB buffer pool is being used or operations on very large tables are being attempted with a huge number of row locks, perhaps comparing several large tables. The only way to fix it for sure is to adjust innodb_buffer_pool_size and restart MySQL. By default, this is set to only 8MB, which is too small for anyone who is using InnoDB to do anything.

Solution
1. Stop MySQL and open my.cnf file which is located in  /opt/lampp/etc/my.cnf  in Linux
2. increase the values of innodb_buffer_pool_size and innodb-log-file-size
for example :

innodb_buffer_pool_size = 2G
innodb-log-file-size = 512 M

innodb-log-file-size should be 25% of innodb_buffer_pool_size

In a dedicated system you can use up to 80% of the total RAM in the system for the InnoDB buffer pool.   
3. Delete the log files ib_logfile0, ib_logfile1 which is located in /opt/lampp/var/mysql 
4. Start MySQL