Java cannot connect to any database server on its own, it requires a JDBC jar driver specific to the database you are using. Luckily, MySQL like many others have this driver available on their website. You need to install it and add it to the class-path for it to work.
sagar podilapu wrote:
I just wanna know what does the error mean?
it says"no suitable driver found."
what does this mean.
And its meaning is same, when you call an URL "jdbc:mysql://localhost/test", DriverManager class, searches a suitable driver as per protocol used, here it searches for MySQL driver, and you know where Java searches for classes, either in JDK_HOME/lib directory or on CLASSPATH ..
I wish I could agree but unfortunately most exception only give you a symptom of the problem and, unlike this case, not exactly what is wrong. Furthermore NullPointerExceptions are still extremely common and often tell you nothing except where the error occurred.
Ok, but many times the understanding of exception messages grows with experience, I too found NPE extremely hard to tackle, but now a days, I can easily avoid them..
After all they are there to help us with best possible reason
Joined: Feb 25, 2009
hey thanks guys for your reply.
I could not understand what you guys talking about.
I am very new to java concepts and I am directly on JDBC concepts.
Could some one help me to rectify the error please.
I have done the classpath seting by copying the .jar file of Connector to ext folder of MySQL
Joined: Feb 25, 2009
I have one more query here.
how to solve the
I even tried
I dont wanna post this in new thread as it is related to connecting to the server
Joined: Mar 22, 2005
sagar podilapu wrote:I have done the classpath seting by copying the .jar file of Connector to ext folder of MySQL
This doesn't sound as if you understand what the classpath is. Do you know what the "-classpath" switch of the java and javac executables do?
However it is too late to post reply in this thread to solve the problem for this user. Any way, I am sure that this thread will keep included in the similar thread facility. So it is necessary to post some reply in order to make it complete.
Well.. this error occurred because we had not put the appropriate jar file on this path, it is as follows:
C:\Program Files\Java\jre\lib\ext\mysql_connector_driver_file.jar (connector can be downloaded from www.mysql.com, and it may have different file name as per i have specified here for demo purposes only.)
So friends please add this file at this path and then re-compile your program and check your result.
The driver class must be known to the connection Driver.
An example with the Oracle driver before trying to establish the connection.
The driver class registers itself with Driver, but only after you made it get loaded for example like this:
I used the dynamic way so that the driver itself is not needed at compile time, only at run time.