mysql - Exception in thread "main" java.sql.SQLException: No suitable driver found for -
i'm trying connect mysql database, created sql database phpmyadmin on localhost. code seems correct , have jar file added eclipse. have googled error , found on here many topics same haven't been able resolve problem. here code:
import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; public class dbconnection { public static void main (string[] args) throws classnotfoundexception, sqlexception { class.forname("com.mysql.jdbc.driver"); connection con = drivermanager.getconnection("jdbc:msql://localhost:3306/g52apr","root", ""); java.sql.preparedstatement statement = con.preparestatement("select * std_details"); resultset result = statement.executequery(); while (result.next()){ system.out.println(result.getstring(1) + " " + result.getstring(2)); } } }
this exact error:
exception in thread "main" java.sql.sqlexception: no suitable driver found jdbc:microsoft:sqlserver://localhost:3306/g52apr @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ dbconnection.main(dbconnection.java:10)
"jdbc:msql://localhost:3306/g52apr"
should be:
"jdbc:mysql://localhost:3306/g52apr"
edited changed sql server reference mysql
Comments
Post a Comment