I am trying to create a calss with a constructior that creates connection with MYSql database , i am using database name as dbetch . I have set the path varable but still it id throwing error

package login;
import java.sql.*;
import java.sql.DriverManager;
import com.mysql.jdbc.Connection;
public class conn {
 Connection con=null;
 ResultSet rs=null;
 Statement st=null;

 public conn() {
  Class.forName("com.mysql.jdbc.Driver");

  con=DriverManager.getConnection("jdbc:mysql://localhost/dbetech","root","");
 }
}

Error thrown

D:\etech\WEB-INF\src>javac *.java
conn.java:18: incompatible types
found   : java.sql.Connection
required: com.mysql.jdbc.Connection
                con=DriverManager.getConnection("jdbc:mysql:///dbetech","root","");

1 error

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Sorry but i am suing follwoing line to craete connection-:

con=DriverManager.getConnection("jdbc:mysql:///dbetech","root","");

Use java.sql.Connection for your "con" variable type. Just change the import type and it will be fine.

This question has already been answered. Start a new discussion instead.