Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Getting "SQLException: No suitable driver" when trying to connect to mysql from eclipse

Reply
Thread Tools

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

 
 
jborup
Guest
Posts: n/a
 
      02-03-2007
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.

 
Reply With Quote
 
 
 
 
zhengxianfu@gmail.com
Guest
Posts: n/a
 
      02-03-2007

> 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.


Can you show us that you have created a connection to server,and logs
on ?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suitable Hosts for .Net 3.5 & Ajax & MySQL DanWeaver ASP .Net 4 04-02-2008 11:32 PM
Trying to connect to a mySQL database and get... Plagued Software 0 06-07-2007 09:14 PM
Getting "SQLException: No suitable driver" when trying to connect to mysql from eclipse jborup Java 2 02-04-2007 04:44 PM
trying to connect to a mysql database, to input a file ewitkop90@hotmail.com Perl Misc 6 01-09-2005 01:46 PM
Seen this message? Can't connect to local MySQL server through socket '/tmp/mysql.sock' Allen Marshall Perl Misc 1 01-24-2004 10:55 PM



Advertisments