• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC + Localhost  RSS feed

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you download the JDBC driver from the MySQL web site? I think it is called jConnector.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
download mysql-connector-java-5.1.12-bin.jar and place it in your lib folder. your problem will be solved
 
Bartender
Posts: 2633
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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!
 
Bnaresh Yad
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean to say is add that jar file into your classpath
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2633
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Abhi.
 
abhi vazhakalil
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jan Cumps wrote:Welcome to JavaRanch, Abhi.




Thanks Jan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!