Two Laptop Bag*
The moose likes JDBC and the fly likes JDBC + Localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC + Localhost" Watch "JDBC + Localhost" New topic
Author

JDBC + Localhost

Behrouz Hosseini
Ranch Hand

Joined: Feb 15, 2010
Posts: 31
Hi guys,
I am new at java and JDBC and I am trying to use JDBC to connect localhost /mysql.
I have this code

but I get this error:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/jdbctest
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DBTest.main(DBTest.java:22)

could you please let me know what I am doing wrong? can you let me know where can I find a useful tutorial regarding this?
Best regards
Behrouz
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

did you download the JDBC driver from the MySQL web site? I think it is called jConnector.
wang lei
Greenhorn

Joined: Mar 09, 2010
Posts: 12
you need to download the JDBC driver from the MySQL web site,
and you can get some userful messages from the sun web site,i think.

In addition to this,i also hava a suggest for you codes,

(my english is very poor and beg your pardon)

'connection.close();' should be put insize finally{} block,such as following codes:


Bnaresh Yad
Greenhorn

Joined: Jan 27, 2010
Posts: 4
download mysql-connector-java-5.1.12-bin.jar and place it in your lib folder. your problem will be solved
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Bnaresh Yad wrote:download mysql-connector-java-5.1.12-bin.jar and place it in your lib folder. your problem will be solved
Hi Bnaresh. What lib folder are you talking about?

And Welcome to JavaRanch!


OCUP UML fundamental and ITIL foundation
youtube channel
Bnaresh Yad
Greenhorn

Joined: Jan 27, 2010
Posts: 4
i mean to say is add that jar file into your classpath
abhi vazhakalil
Greenhorn

Joined: Mar 24, 2010
Posts: 4
Hey, this is a common issue which most of the beginners come across. What you need to do is just download the jar myql jar file and add this file under your libraries. This issue will be solved.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Welcome to JavaRanch, Abhi.
abhi vazhakalil
Greenhorn

Joined: Mar 24, 2010
Posts: 4
Jan Cumps wrote:Welcome to JavaRanch, Abhi.



Thanks Jan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC + Localhost
 
Similar Threads
Is there a MySQL server running on the machine/port you are trying to connect to?
somebody come in and help me check this error
java.sql.SQLException: No suitable driver
java.sql.SQLException: No suitable driver
JDBC Error