java - MySql (MAMP) jdbc connection error in eclipse -


i trying set connection mysql in eclipse. have tried following -

  1. i have added "my-sql-connector.jar" build path , class path.
  2. i have tried adding in web-inf.
  3. tried using class.forname.

after trying above, still not able set connection. keep getting following error -

java.sql.sqlexception: no suitable driver found jdbc:mysql://localhost/sampledb

here code -

public class main {      private static final string username = "user1";     private static final string password = "user1";     private static final string conn_string =             "jdbc:mysql://localhost/sampledb";      public static void main(string[] args) throws sqlexception {          connection conn = null;         try {             conn = drivermanager.getconnection(conn_string, username, password);             system.out.println("connected");         } catch (sqlexception e) {              system.err.println(e);         } {              if (conn != null) {                 conn.close();             }         } 

i have seen multiple posts on issue , have tried of suggestions. new java , trying hands on java , jdbc, stuck last 2 days. can please guide me issue?

did try registering driver? , check if driver proper.

class.forname("com.mysql.jdbc.driver"); conn = (connection) drivermanager.getconnection(conn_string, username, password); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -