java - No suitable driver found for 'jdbc:mysql://localhost:3306/mysql -


this question has answer here:

using java, error when attempting connect mysql database:

java.sql.sqlexception: no suitable driver found  'jdbc:mysql://localhost:3306/mysql @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ mytest1.main(mytest1.java:28) 

i'm using mysql-connector-java-5.1.18-bin.jar driver. in build path. have restarted mysql. i've logged on command line root , no password , connected fine. i'm not seeing port 3306 in netstat. getting different error (i didn't change code). error "jdbc mysql access denied user 'root'@'localhost password no"

try {     class.forname("com.mysql.jdbc.driver"); }  catch (classnotfoundexception e) {     // todo auto-generated catch block     e.printstacktrace(); }    try {     string url = "'jdbc:mysql://localhost:3306/mysql";     connection con = drivermanager.getconnection(url, "root", ""); } catch (exception e){     e.printstacktrace(); } 

in particular case (assuming class#forname() didn't threw exception; code namely continuing running instead of throwing exception), sqlexception means driver#acceptsurl() has returned false of loaded drivers.

and indeed, jdbc url wrong:

string url = "'jdbc:mysql://localhost:3306/mysql"; 

remove singlequote:

string url = "jdbc:mysql://localhost:3306/mysql"; 

see also:


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -