• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

connection problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here's my code
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;

public class Testdb {

public static void main(String[] argv) throws ClassNotFoundException, SQLException {

System.out.println("-------- MySQL JDBC Connection Testing ------------");


Class.forName("com.mysql.jdbc.Driver");

System.out.println("MySQL JDBC Driver Registered!");
Connection connection = null;


connection = DriverManager
.getConnection("jdbc:mysql:\\localhost:3306/local MYSQL55","root", "root");



if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
}
output:
-------- MySQL JDBC Connection Testing ------------
MySQL JDBC Driver Registered!
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql:\localhost:3306/hello
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Testdb.main(Testdb.java:19)
i have added mysql-connector-java-5.1.22-bin.jar .
but still it is giving me error
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Replace the \\ with //.
 
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic