Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Getting "SQLException: No suitable driver" when trying to connect to mysql from eclipse

Thread view: 
jborup - 03 Feb 2007 08:56 GMT
Hi community,,,
I hope you can help. I do believe this is small problem. I have seen
the problem raised several places at the net, but not found a
solution.

I want to connect to a mysql db on a server, from the client where I
do the development. Its done in java, using the eclipse ide, its just
a small 'hello world' type stand alone java program. I have used some
sample code, and when I compile I get "SQLException: No suitable
driver". From searching the internet, the problem should be, that I
don't have the mysql jar file in my path. To "my project" ->
properties -> Libraries, I have added a external jar, and selected the
mysql. jar (running ubuntu - found the jar file in: /usr/share/java/
mysql.jar). When running then program I still get the error.
I have also tried from within the class, right click, select 'run as' -
> run, some run configurations appears. In the classpath I have added
the mysql.jar as a external jar. I still get the 'No suitable driver'.

You could think, that the driver is bad, but from the 'Database
development' perspective, using the mysql.jar,  I have created a
connection to the server, which logs on, and shows the tables in the
db. So I guess the driver is ok,

My develoment client, is running ubuntu, eclipse 3.2.1, Mysql driver
4.x (guess its jdbc 3?)

This is the sample code:

// import static java.lang.System.out.*;
import static java.lang.System.out;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class HelloWorld {

    /**
    * @param args
    */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Hello World");

        try {
           Connection conn =
              DriverManager.getConnection("jdbc:mysql://<server>:3306/
BudgetDev?"+
   
"user=<user>&password=<password>");

        } catch (SQLException ex) {
           // handle any errors
           System.out.println("SQLException: " + ex.getMessage());
           System.out.println("SQLState: " + ex.getSQLState());
           System.out.println("VendorError: " + ex.getErrorCode());
        }

    }

}

Hope some can help.
Arne Vajhøj - 03 Feb 2007 15:03 GMT
>     public static void main(String[] args) {
>         // TODO Auto-generated method stub
>         System.out.println("Hello World");
>
>         try {

Class.forName("com.mysql.jdbc.Driver");

>            Connection conn =
>               DriverManager.getConnection("jdbc:mysql://<server>:3306/
> BudgetDev?"+
>    
> "user=<user>&password=<password>");

Arne
jborup - 04 Feb 2007 16:44 GMT
Thank you.....

Than solved the problem.
Regards Jørn Borup

> >    public static void main(String[] args) {
> >            // TODO Auto-generated method stub
[quoted text clipped - 11 lines]
>
> Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.