"No suitable driver" exception [message #35561] |
Mon, 27 August 2007 15:43 |
Eclipse User |
|
|
|
Originally posted by: xstang.atlas.cz
while trying to connect to nysql db I always get an exception message "No
suitable driver".
If I try to connect through Data Source Explorer, it works fine.
Can anyone help me with that?
I'm new to Eclipse, so it may be just a stupid small thing, but I can't
figure it out.
Thanx
|
|
|
Re: "No suitable driver" exception [message #35595 is a reply to message #35561] |
Mon, 27 August 2007 18:47 |
Eclipse User |
|
|
|
Originally posted by: brianf.sybase.com
Hi... Can you provide some additional details about how you're trying to get
a connection?
Thanks
--Brian Fitzpatrick
Sr. Software Engineer/DTP Connectivity
Sybase, Inc
"xstang" <xstang@atlas.cz> wrote in message
news:a6feeb2163692b9a9e610ed0106a6d14$1@www.eclipse.org...
> while trying to connect to nysql db I always get an exception message "No
> suitable driver".
> If I try to connect through Data Source Explorer, it works fine.
>
> Can anyone help me with that? I'm new to Eclipse, so it may be just a
> stupid small thing, but I can't figure it out.
> Thanx
>
|
|
|
|
Re: "No suitable driver" exception [message #35764 is a reply to message #35730] |
Thu, 30 August 2007 13:36 |
Eclipse User |
|
|
|
Originally posted by: brianf.sybase.com
Hi there...
This is fine code, but you have to make sure that the driver is loaded
before you call to get a connection.
If you're developing a plug-in, you can use the Driver Instance to get a
classloader with the associated jars already there. However, since the
example you provided was a simple main(), I'm guessing you're just doing
straight Java development.
This is more of a JDBC thing, but you typically have to load the class ahead
of time by adding the driver jar(s) to the project classpath and then using
something like...
try {
Class.forName("my.jdbc.driver.class");
}
catch(Exception x){
System.out.println( "Unable to load the driver class!" );
}
This will load the jar into the classloader so the JDBC DriverManager can
see it and you should then be able to use your code.
If you're doing things within an Eclipse plug-in, we have other options
available within DTP to help you out.
Hope that helps.
--Fitz
"xstang" <xstang@atlas.cz> wrote in message
news:b064ba84538d8f9b1956de1529085677$1@www.eclipse.org...
> Hi,
>
> that's the code:
>
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.SQLException;
> ..
> public class to {
> public static void main(String[] args) {
>
> try {
> Connection conn =
> DriverManager.getConnection("jdbc:mysql://localhost:3306/test"); }
> catch (SQLException ex) {
> ...
> } }
> }
>
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02921 seconds