I am calling this constructor but it is not getting complied

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

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

throwing error message:

D:\etech\WEB-INF\src>javac *.java
conn.java:16: 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

this has nothing to do with JSP...

And you seem to have defined your instance (I hope) variable conn as being of the wrong type.

Anyway, what you're doing is terrible. You should never open connections to external resources at a different place from where you're going to close them.
Doing so is a recipe for disaster.

Hi

Yes it has nothing to do JSP but since its part of Core java and it is used for bussiness loin i put it here.

and i modified the code and it worked for me ,,this is modified code -:

public class conn {

Connection con=null;
ResultSet rs=null;
Statement st=null;

public conn()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql:///dbetech","root","");
}
catch (Exception e) {
System.out.println(e);
}
}
}

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