ClassNotFoundException com.mysql.jdbc.Driver myeclipse indigo Resolved

Open myeclipse indigo
Create New Java Project.
Add a Class file and write the code shown below for connecting to mysql
Download mysql-connector-java-5.1.21.jar file and add it to myeclipse Run Configurations
Keep the jar file in CLASSPATH environment variable
Include in Java build path also by adding External Jar.

After doing all the above steps I see the below error message. Checked lot of forums and searched google for more than 2 days, every step that I did was correct and nothing looks wrong. 
But still I can't connect to mysql.

Error Messages : 
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at database.Connect.ConnectDB(Connect.java:16)

Error Message : 
No Suitable Driver for jdbc:mysql://localhost:3306/test

Program written in myeclipse indigo IDE
  1. package database;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. public class Connect {
  5. public Connection ConnectDB()
  6. {
  7. Connection conn = null;
  8. try
  9. {
  10. String userName = "root";
  11. String password = "planet";
  12. String url = "jdbc:mysql://localhost:3306/test";
  13. Class.forName ("com.mysql.jdbc.Driver").newInstance();
  14. conn = DriverManager.getConnection (url, userName, password);
  15. System.out.println ("Database connection established");
  16. }
  17. catch (Exception e)
  18. {
  19. e.printStackTrace();
  20. }
  21. return (conn);
  22. }
  23. }

Resolution :

After checking lot of articles on the internet, I couldn't figure out what is going wrong in my eclipse.
The mistake I did was, I downloaded mysql-connector-java-5.1.21.zip file from mysql downloads section and setting the PATH to this file and added the same zip file to the external JAR.

To solve my problem I extracted the ZIP file which internally contains mysql-connector-java-5.1.21.jar file. Once we have the real jar file we should use this file every where. This solved my problem.

Hope this helps anyone out there..  If anyone finds this useful please leave a comment




Mysql Time Zone is different from System Time zone

I changed System Time Zone to IST. But mysql is showing different timezone.

To know what time zone mysql is using, type below command.

sql> show variables like '%time_zone%';

+------------------+------------------------+
| Variable_name    | Value                  |
+------------------+------------------------+
| system_time_zone | Mountain Standard Time |
| time_zone        | SYSTEM                 |
+------------------+------------------------+


To get this change in MySql simple open services and search for MySql Service and restart it.
This should change your MySql Timezone as well.

Eclipse Indigo Hangs : Java was started but returned exit code

Eclipse suddenly started to hang when starting up around “Loading Workbench”. Eclipse stopped responding and you get the dialog to close the program.
The error shown afterwards:
“Java was started but returned exit code=-805306369″
If you are running java 1.6u21 then look at Eclipse Bug 319514 and The Oracle/Sun fix on Eclipse wiki site.
This however wasn’t the problem as I was running Java 1.6.0_31b05. Tried to uninstall and reinstall Java but no success. Tried to look through the plugins I was using but nothing.
The error was due to a corrupt workspace. As I disable the workspace check in the startup I couldn’t select another workspace since Eclipse wouldn’t start. Rename the workspace e.g. to “workspace1″. Eclipse will start and create a new uncorrupted workspace and work without any problems. Afterwards you can import your project into your new workspace and in the end remove the old corrupted workspace.
Alternatively, I solve this type of hangs as follows. Goto Workspace folder Backup .metadata folder some where and delete it from workspace folder, now open eclipse IDE and a .metadata folder is created. Now close eclipse and copy all the contents from .metadata folder which is backed up into the new .metadata file ,now open Eclipse it should start normally.



javax.servlet.jsp.JspWriter cannot be resolved to a type

I suddenly got this error message and not sure what went wrong, after searching for sometime I found the below solution which resolved this problem.

Try doing these steps in your eclipse IDE and this should solve your problem

  1. Go to "Project->Properties->Validation".
  2. Click "Configure Workspace Settings...".
  3. Unselect options for JSP Syntax Validator. You need to uncheck both manual and build

How to Insert Image in email yahoomail / gmail

I am going to explain how to insert Images within the email (Inline).

The best way which I use most of the times is to upload the desired image in any image hosting website and use the link. I will explain how to do this step by step.

Goto any Image Hosting website, generally I use http://imageshack.us
If you have an account with it you can login/ No problem even if you don't have any account.

Browse your image from your computer and upload it.























I like the feature 'Image resize', it reduces the original image into the selected size and uploads.
































Once the image is uploaded you will be given with a link.
Copy the Direct Link and open it in Mozilla Firefox or Internet Explorer.









































Only Image should be opened. After opening the image press Ctrl + A (Select All) and copy the image Ctrl + C (Copy).
This will copy the image as Rich Text Format.

Now compose a mail and paste (Ctrl+V) it in the mail body. This works in yahoo / gmail. I guess this works in any Web mail client.


Gmail Feature

Recently gmail released a new Lab version to insert images in email. You will have an Image Button in gmail .


















If you don't see such icon. Enable it from Labs.
Goto Settings (Click gear Icon and Click on Settings)
Goto labs and enable Inserting I images, as shown below.
Now you will see insert image icon while composing an email.




























To Insert an Image using Insert Image.
1. Click on insert Image icon and browse the Image from MyComputer as shown below and click OK